def get_kpi_static_data(self): """ This function extracts the static KPI data and saves it into one global data frame. The data is taken from static.kpi / static.atomic_kpi / static.kpi_set. """ query = DIAGEOQueries.get_all_kpi_data() kpi_static_data = pd.read_sql_query(query, self.rds_conn.db) return kpi_static_data
def get_match_display(self): """ This function extracts the display matches data and saves it into one global data frame. The data is taken from probedata.match_display_in_scene. """ query = DIAGEOQueries.get_match_display(self.session_uid) match_display = pd.read_sql_query(query, self.rds_conn.db) return match_display
def get_business_unit(self): """ This function returns the session's business unit (equal to store type for some KPIs) """ query = DIAGEOQueries.get_business_unit_data( self.store_info['store_fk'].values[0]) business_unit = pd.read_sql_query(query, self.rds_conn.db)['name'] if not business_unit.empty: return business_unit.values[0] else: return ''
def get_business_unit_name(self): """ This function extracts the static KPI data and saves it into one global data frame. The data is taken from static.kpi / static.atomic_kpi / static.kpi_set. """ query = DIAGEOQueries.get_business_unit_name(self.store_id) business_unit_name = pd.read_sql_query(query, self.rds_conn.db) if business_unit_name['business_unit_name'].empty: return "" else: return business_unit_name['business_unit_name'].values[0]
def commit_results_data(self): """ This function writes all KPI results to the DB, and commits the changes. """ cur = self.rds_conn.db.cursor() delete_queries = DIAGEOQueries.get_delete_session_results_query_old_tables(self.session_uid) for query in delete_queries: cur.execute(query) for query in self.kpi_results_queries: cur.execute(query) self.rds_conn.db.commit()
def commit_results_data(self): """ This function writes all KPI results to the DB, and commits the changes. """ insert_queries = self.merge_insert_queries(self.kpi_results_queries) rds_conn = PSProjectConnector(self.project_name, DbUsers.CalculationEng) cur = rds_conn.db.cursor() delete_queries = DIAGEOQueries.get_delete_session_results_query_old_tables( self.session_uid) for query in delete_queries: cur.execute(query) for query in insert_queries: cur.execute(query) rds_conn.db.commit()
def commit_results_data(self): # self.common.commit_results_data_to_new_tables() self.common_v2.commit_results_data() # new tables # old tables cur = self.rds_conn.db.cursor() delete_queries = DIAGEOQueries.get_delete_session_results_query_old_tables( self.session_uid) for query in delete_queries: cur.execute(query) for query in self.kpi_results_queries: cur.execute(query) # needed to save Touch Point values for query in self.common.kpi_results_queries: cur.execute(query) # this is only needed temporarily until the global assortment function is updated to use the new commonv2 object insert_queries = self.common.merge_insert_queries( self.common.kpi_results_new_tables_queries) for query in insert_queries: cur.execute(query) self.rds_conn.db.commit()