예제 #1
0
 def __init__(self, data_provider, output):
     self.output = output
     self.data_provider = data_provider
     self.project_name = self.data_provider.project_name
     self.session_uid = self.data_provider.session_uid
     self.products = self.data_provider[Data.PRODUCTS]
     self.all_products = self.data_provider[Data.ALL_PRODUCTS]
     self.match_product_in_scene = self.data_provider[Data.MATCHES]
     self.visit_date = self.data_provider[Data.VISIT_DATE]
     self.session_info = self.data_provider[Data.SESSION_INFO]
     self.scene_info = self.data_provider[Data.SCENES_INFO]
     self.store_id = self.data_provider[Data.STORE_FK]
     self.store_info = self.data_provider[Data.STORE_INFO]
     self.store_channel = self.store_info['store_type'].values[0]
     if self.store_channel:
         self.store_channel = self.store_channel.upper()
     self.store_type = self.store_info['additional_attribute_1'].values[0]
     self.scif = self.data_provider[Data.SCENE_ITEM_FACTS]
     self.rds_conn = PSProjectConnector(self.project_name,
                                        DbUsers.CalculationEng)
     self.tools = INBEVCOINBEVCOGENERALToolBox(self.data_provider,
                                               self.output,
                                               rds_conn=self.rds_conn)
     self.kpi_static_data = self.get_kpi_static_data()
     self.kpi_results_queries = []
     self.relative_positioning = parse_template(TEMPLATE_PATH,
                                                'Relative Positioning',
                                                lower_headers_row_index=2)
     self.brand_blocking = parse_template(TEMPLATE_PATH,
                                          'Brand Blocking',
                                          lower_headers_row_index=6)
     self.purity = parse_template(TEMPLATE_PATH,
                                  'Purity',
                                  lower_headers_row_index=3)
예제 #2
0
 def __init__(self, data_provider, output):
     self.output = output
     self.data_provider = data_provider
     self.project_name = self.data_provider.project_name
     self.common = Common(self.data_provider)
     self.old_common = oldCommon(self.data_provider)
     self.rds_conn = PSProjectConnector(self.project_name,
                                        DbUsers.CalculationEng)
     self.session_fk = self.data_provider.session_id
     self.match_product_in_scene = self.data_provider[Data.MATCHES]
     self.scif = self.data_provider[Data.SCENE_ITEM_FACTS]
     self.store_info = self.data_provider[Data.STORE_INFO]
     self.store_id = self.data_provider[Data.STORE_FK]
     self.survey = Survey(self.data_provider)
     self.block = Block(self.data_provider)
     self.general_toolbox = GENERALToolBox(self.data_provider)
     self.visit_date = self.data_provider[Data.VISIT_DATE]
     self.template_path = self.get_relevant_template()
     self.gap_data = self.get_gap_data()
     self.kpi_weights = parse_template(self.template_path,
                                       Consts.KPI_WEIGHT,
                                       lower_headers_row_index=0)
     self.template_data = self.parse_template_data()
     self.kpis_gaps = list()
     self.passed_availability = list()
     self.kpi_static_data = self.old_common.get_kpi_static_data()
     self.own_manufacturer_fk = int(
         self.data_provider.own_manufacturer.param_value.values[0])
     self.parser = Parser
     self.all_products = self.data_provider[Data.ALL_PRODUCTS]
예제 #3
0
 def mock_parse_template_data(self):
     template_mock = self.mock_object(
         'CBCDAIRYILToolBox.parse_template_data')
     template_data = parse_template(os.path.join(
         os.path.dirname(os.path.realpath(__file__)), 'Data',
         'test_template.xlsx'),
                                    Consts.KPI_SHEET,
                                    lower_headers_row_index=1)
     template_mock.return_value = template_data
예제 #4
0
 def get_gap_data(self):
     """
     This function parse the gap data template and returns the gap priorities.
     :return: A dict with the priorities according to kpi_names. E.g: {kpi_name1: 1, kpi_name2: 2 ...}
     """
     gap_sheet = parse_template(self.template_path,
                                Consts.KPI_GAP,
                                lower_headers_row_index=0)
     gap_data = zip(gap_sheet[Consts.KPI_NAME], gap_sheet[Consts.ORDER])
     gap_data = {kpi_name: int(order) for kpi_name, order in gap_data}
     return gap_data
예제 #5
0
 def parse_template_data(self):
     """
     This function responsible to filter the relevant template data..
     :return: A DataFrame with filtered Data by store attributes.
     """
     kpis_template = parse_template(self.template_path,
                                    Consts.KPI_SHEET,
                                    lower_headers_row_index=1)
     relevant_store_info = self.get_store_attributes(
         Consts.STORE_ATTRIBUTES_TO_FILTER_BY)
     filtered_data = self.filter_template_by_store_att(
         kpis_template, relevant_store_info)
     return filtered_data