예제 #1
0
 def __init__(self, data_provider):
     self.data_provider = data_provider
     self.common = CommonV2(self.data_provider)
     self.project_name = self.data_provider.project_name
     self.session_uid = self.data_provider.session_uid
     self.manufacturer_fk = 1
     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.scif = self.data_provider[Data.SCENE_ITEM_FACTS]
     self.scif = self.scif[~(self.scif['product_type'] == 'Irrelevant')]
     self.region = self.store_info['region_name'].iloc[0]
     self.store_type = self.store_info['store_type'].iloc[0]
     self.program = self.store_info['additional_attribute_3'].iloc[0]
     if self.store_type in STORE_TYPES:  #####
         self.store_type = STORE_TYPES[self.store_type]  ####
     self.store_attr = self.store_info['additional_attribute_3'].iloc[0]
     self.session_results = self.get_session_kpi_results()
     self.parent_frame = pd.DataFrame()
     self.results = self.data_provider[Data.SCENE_KPI_RESULTS]
     self.hierarchy_table = pd.DataFrame(columns=self.COLUMNS)
     self.session_hierarchy_table = pd.DataFrame(columns=self.COLUMNS)
예제 #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.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.scif = self.data_provider[Data.SCENE_ITEM_FACTS]
        self.rds_conn = PSProjectConnector(self.project_name,
                                           DbUsers.CalculationEng)
        self.store_info = self.data_provider[Data.STORE_INFO]
        self.store_type = self.store_info['additional_attribute_1'].values[0]
        self.kpi_static_data = self.get_kpi_static_data()
        self.set_templates_data = {}
        self.match_display_in_scene = self.get_match_display()
        self.kpi_results_queries = []
        self.scores = {self.LEVEL1: {}, self.LEVEL2: {}, self.LEVEL3: {}}

        self.output = output
        self.common = Common(self.data_provider)
        self.commonV2 = CommonV2(self.data_provider)
        self.global_gen = DIAGEOGenerator(self.data_provider, self.output,
                                          self.common)
        self.tools = DIAGEOToolBox(
            self.data_provider,
            output,
            match_display_in_scene=self.match_display_in_scene
        )  # replace the old one
        self.diageo_generator = DIAGEOGenerator(self.data_provider,
                                                self.output, self.common)
예제 #3
0
 def __init__(self, data_provider, output):
     self.k_engine = BaseCalculationsScript(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.rds_conn = PSProjectConnector(self.project_name, DbUsers.CalculationEng)
     self.store_info = self.data_provider[Data.STORE_INFO]
     self.store_id = self.data_provider[Data.STORE_FK]
     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.segment = self.get_business_unit_name()
     self.scene_info = self.data_provider[Data.SCENES_INFO]
     self.scif = self.data_provider[Data.SCENE_ITEM_FACTS]
     self.match_display_in_scene = self.get_match_display()
     self.set_templates_data = {}
     self.kpi_static_data = self.get_kpi_static_data()
     self.tools = DIAGEOToolBox(self.data_provider, output, match_display_in_scene=self.match_display_in_scene)
     self.kpi_results_queries = []
     self.common = Common(self.data_provider)
     self.commonV2 = CommonV2(self.data_provider)
     self.diageo_generator = DIAGEOGenerator(self.data_provider, self.output, self.common)
예제 #4
0
 def __init__(self, data_provider, output):
     self.output = output
     self.data_provider = data_provider
     self.common_v2 = CommonV2(self.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.templates = self.data_provider[Data.TEMPLATES]
     self.scene_info = self.data_provider[Data.SCENES_INFO]
     self.store_info = self.data_provider[Data.STORE_INFO]
     self.store_id = self.data_provider[Data.STORE_FK]
     self.scif = self.data_provider[Data.SCENE_ITEM_FACTS]
     self.own_manufacturer_fk = int(self.data_provider.own_manufacturer.param_value.values[0])
     self.rds_conn = PSProjectConnector(self.project_name, DbUsers.CalculationEng)
     self.kpi_static_data = self.common_v2.get_kpi_static_data()
     self.kpi_results_queries = []
     self.template = self.data_provider.all_templates  # templates
     self.toolbox = GENERALToolBox(data_provider)
     kpi_path = os.path.dirname(os.path.realpath(__file__))
     base_file = os.path.basename(kpi_path)
     self.exclude_filters = pd.read_excel(os.path.join(kpi_path[:- len(base_file)], 'Data', 'template.xlsx'),
                                          sheetname="Exclude")
     self.Include_filters = pd.read_excel(os.path.join(kpi_path[:- len(base_file)], 'Data', 'template.xlsx'),
                                          sheetname="Include")
     self.bay_count_kpi = pd.read_excel(os.path.join(kpi_path[:- len(base_file)], 'Data', 'template.xlsx'),
                                        sheetname="BayCountKPI")
     self.assortment_data = pd.read_excel(os.path.join(kpi_path[:- len(base_file)], 'Data', 'template.xlsx'),
                                          sheetname="Assortment")
예제 #5
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.rds_conn = PSProjectConnector(self.project_name, DbUsers.CalculationEng)
     # self.store_type = self.data_provider[Data.STORE_INFO]['store_type'].iloc[0]
     query_store_type = CCZAQueries.get_attr3(self.session_uid)
     store_type = pd.read_sql_query(query_store_type, self.rds_conn.db)
     self.store_type = store_type[Const.ATTR3].iloc[0]
     self.scif = self.data_provider[Data.SCENE_ITEM_FACTS]
     self.tools = GENERALToolBox(self.data_provider, self.output, rds_conn=self.rds_conn)
     self.survey_response = self.data_provider[Data.SURVEY_RESPONSES]
     self.tool_box_for_flow = ToolBox
     # create data-frames from template
     self.kpi_sheets = {}
     for name in Const.sheet_names_and_rows:
         self.kpi_sheets[name] = parse_template(TEMPLATE_PATH, sheet_name=name,
                                                lower_headers_row_index=Const.sheet_names_and_rows[name])
     self.common = Common(self.data_provider, Const.RED_SCORE)
     self.survey_handler = Survey(self.data_provider, self.output, self.kpi_sheets[Const.SURVEY_QUESTIONS])
     self.kpi_static_data = self.common.kpi_static_data
     self.kpi_results_queries = []
     self.common_v2 = CommonV2(self.data_provider)
     self.own_manuf_fk = self.get_own_manufacturer_fk()
     self.scif_match_react = self.scif[self.scif[ScifConsts.RLV_SOS_SC] == 1]
예제 #6
0
 def __init__(self, data_provider, output):
     self.data_provider = data_provider
     self.scif = self.data_provider[Data.SCENE_ITEM_FACTS]
     self.output = output
     self.common = Common(self.data_provider)
     self.commonV2 = CommonV2(self.data_provider)
     self.diageo_generator = DIAGEOGenerator(self.data_provider, self.output, self.common)
예제 #7
0
 def __init__(self, data_provider, output):
     self.k_engine = BaseCalculationsScript(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_type = self.store_info['store_type'].iloc[0]
     self.scif = self.data_provider[Data.SCENE_ITEM_FACTS]
     self.rds_conn = PSProjectConnector(self.project_name, DbUsers.CalculationEng)
     self.general_tools = CCKHGENERALToolBox(self.data_provider, self.output)
     self.template = CCKHTemplateConsts()
     self.kpi_static_data = self.get_kpi_static_data()
     self.kpi_results_queries = []
     self.commonV2 = CommonV2(self.data_provider)
     self.kpi_new_static_data = self.commonV2.get_new_kpi_static_data()
     self.manufacturer = int(self.data_provider.own_manufacturer.param_value.values[0])
     self.ps_data_provider = PsDataProvider(self.data_provider, self.output)
     self.external_targets = self.ps_data_provider.get_kpi_external_targets()
     self.assortment = Assortment(self.data_provider, self.output)
     self.templates_info = self.external_targets[self.external_targets[CCKHTemplateConsts.TEMPLATE_OPERATION] ==
                                                 CCKHTemplateConsts.BASIC_SHEET]
     self.visibility_info = self.external_targets[self.external_targets[CCKHTemplateConsts.TEMPLATE_OPERATION]
                                                  == CCKHTemplateConsts.VISIBILITY_SHEET]
     self.cooler_info = self.external_targets[self.external_targets[CCKHTemplateConsts.TEMPLATE_OPERATION]
                                              == CCKHTemplateConsts.COOLER_SHEET]
예제 #8
0
 def __init__(self, data_provider, output):
     self.output = output
     self.data_provider = data_provider
     self.common_v2 = CommonV2(self.data_provider)
     self.common_v1 = CommonV1(self.data_provider)
     self.data_provider.common_v2 = self.common_v2
     self.data_provider.common_v1 = self.common_v1
     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.scif = self.data_provider[Data.SCENE_ITEM_FACTS]
     self.rds_conn = PSProjectConnector(self.project_name,
                                        DbUsers.CalculationEng)
     self.channel = self.get_store_channel(self.store_id)
     self.kpi_static_data = self.common_v2.get_kpi_static_data()
     self.data_provider.kpi_sheets = {}
     self.kpi_sheets = self.data_provider.kpi_sheets
     self.old_kpi_static_data = self.common_v1.get_kpi_static_data()
     for name in SHEETS_NAME:
         parsed_template = ParseTemplates.parse_template(TEMPLATE_PATH,
                                                         sheet_name=name)
         self.kpi_sheets[name] = parsed_template[parsed_template['Channel']
                                                 == self.channel]
     self.data_provider.sos = SOS(self.data_provider, output=None)
     self.data_provider.assortment = Assortment(self.data_provider,
                                                output=None)
예제 #9
0
 def __init__(self, data_provider, output):
     self.output = output
     self.data_provider = data_provider
     self.common = Common(self.data_provider)
     self.commonV2 = CommonV2(self.data_provider)
     self.project_name = self.data_provider.project_name
     self.session_uid = self.data_provider.session_uid
     self.k_engine = BaseCalculationsGroup(data_provider, output)
     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.scif = self.data_provider[Data.SCENE_ITEM_FACTS]
     self.rds_conn = PSProjectConnector(self.project_name, DbUsers.CalculationEng)
     self.kpi_static_data = self.commonV2.get_kpi_static_data()
     self.kpi_results_queries = []
     self.templates = {}
     self.all_products = self.commonV2.data_provider[Data.ALL_PRODUCTS]
     self.session_id = self.data_provider.session_id
     self.score_templates = {}
     self.get_templates()
     self.get_score_template()
     self.manufacturer_fk = self.all_products[
         self.all_products['manufacturer_name'] == 'Coca Cola'].iloc[0]
     self.sos = SOS(self.data_provider, self.output)
     self.total_score = 0
     self.session_fk = self.data_provider[Data.SESSION_INFO]['pk'].iloc[0]
     self.toolbox = GENERALToolBox(self.data_provider)
     self.scenes_info = self.data_provider[Data.SCENES_INFO]
     self.kpi_results_new_tables_queries = []
예제 #10
0
    def __init__(self, data_provider, output):
        self.output = output
        self.data_provider = data_provider
        self.common = Common(self.data_provider)
        self.common_v2 = CommonV2(self.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.scif = self.data_provider[Data.SCENE_ITEM_FACTS]
        self.template_info = self.data_provider.all_templates
        self.rds_conn = ProjectConnector(self.project_name,
                                         DbUsers.CalculationEng)
        self.ps_data_provider = PsDataProvider(self.data_provider)
        self.thresholds_and_results = {}
        self.result_df = []
        self.writing_to_db_time = datetime.timedelta(0)
        self.kpi_results_queries = []
        self.potential_products = {}
        self.shelf_square_boundaries = {}
        self.average_shelf_values = {}
        self.kpi_static_data = self.common.get_kpi_static_data()
        self.kpi_results_queries = []
        self.all_template_data = parse_template(TEMPLATE_PATH, "KPI")
        self.spacing_template_data = parse_template(TEMPLATE_PATH, "Spacing")
        self.fixture_width_template = pd.read_excel(FIXTURE_WIDTH_TEMPLATE,
                                                    "Fixture Width",
                                                    dtype=pd.Int64Dtype())
        self.facings_to_feet_template = pd.read_excel(FIXTURE_WIDTH_TEMPLATE,
                                                      "Conversion Table",
                                                      dtype=pd.Int64Dtype())
        self.header_positions_template = pd.read_excel(FIXTURE_WIDTH_TEMPLATE,
                                                       "Header Positions")
        self.flip_sign_positions_template = pd.read_excel(
            FIXTURE_WIDTH_TEMPLATE, "Flip Sign Positions")
        self.custom_entity_data = self.ps_data_provider.get_custom_entities(
            1005)
        self.ignore_stacking = False
        self.facings_field = 'facings' if not self.ignore_stacking else 'facings_ign_stack'
        self.INCLUDE_FILTER = 1
        self.assortment = Assortment(self.data_provider,
                                     output=self.output,
                                     ps_data_provider=self.ps_data_provider)
        self.store_assortment = self.assortment.get_lvl3_relevant_ass()

        self.kpi_new_static_data = self.common.get_new_kpi_static_data()
        try:
            self.mpis = self.match_product_in_scene.merge(self.products, on='product_fk', suffixes=['', '_p']) \
                        .merge(self.scene_info, on='scene_fk', suffixes=['', '_s']) \
                          .merge(self.template_info, on='template_fk', suffixes=['', '_t'])
        except KeyError:
            Log.warning('MPIS cannot be generated!')
            return
        self.adp = AltriaDataProvider(self.data_provider)
예제 #11
0
 def __init__(self, data_provider, output):
     self.output = output
     self.data_provider = data_provider
     self.project_name = data_provider.project_name
     self.scif = self.data_provider[Data.SCENE_ITEM_FACTS]
     self.common = Common(self.data_provider)
     self.commonV2 = CommonV2(self.data_provider)
     self.diageo_generator = DIAGEOGenerator(self.data_provider, self.output, self.common)
     self.template_handler = TemplateHandler(self.project_name)
예제 #12
0
 def __init__(self, data_provider, output):
     self.data_provider = data_provider
     self.project_name = self.data_provider.project_name
     self.ps_data_provider = PsDataProvider(data_provider)
     self.store_id = self.data_provider[Data.STORE_FK]
     self.scif = self.data_provider[Data.SCENE_ITEM_FACTS]
     self.output = output
     self.common = Common(self.data_provider)
     self.commonV2 = CommonV2(self.data_provider)
     self.diageo_generator = DIAGEOGenerator(self.data_provider,
                                             self.output, self.common)
     self.rds_conn = PSProjectConnector(self.project_name,
                                        DbUsers.CalculationEng)
     self.session_uid = self.data_provider.session_uid
예제 #13
0
    def __init__(self, data_provider, output):
        self.output = output
        self.data_provider = data_provider
        self.project_name = self.data_provider.project_name
        self.commonV2 = CommonV2(self.data_provider)
        self.common = Common(self.data_provider)
        self.assortment = Assortment(self.data_provider, self.output)

        self.own_manuf_fk = int(
            self.data_provider.own_manufacturer.param_value.values[0])
        self.store_info = self.data_provider[Data.STORE_INFO]
        self.new_kpi_static_data = self.commonV2.get_new_kpi_static_data()
        self.all_products_include_deleted = self.data_provider[
            Data.ALL_PRODUCTS_INCLUDING_DELETED]
        self.visit_date = self.data_provider[Data.VISIT_DATE]
예제 #14
0
 def __init__(self, data_provider, output):
     self.output = output
     self.data_provider = data_provider
     self.common = Common(self.data_provider)
     self.common_v2 = CommonV2(self.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.scif = self.data_provider[Data.SCENE_ITEM_FACTS]
     self.template_info = self.data_provider.all_templates
     self.rds_conn = ProjectConnector(self.project_name, DbUsers.CalculationEng)
     self.ps_data_provider = PsDataProvider(self.data_provider)
     self.match_product_in_probe_state_reporting = self.ps_data_provider.get_match_product_in_probe_state_reporting()
     self.kpi_results_queries = []
     self.fixture_width_template = pd.read_excel(FIXTURE_WIDTH_TEMPLATE, "Fixture Width", dtype=pd.Int64Dtype())
     self.facings_to_feet_template = pd.read_excel(FIXTURE_WIDTH_TEMPLATE, "Conversion Table", dtype=pd.Int64Dtype())
     self.header_positions_template = pd.read_excel(FIXTURE_WIDTH_TEMPLATE, "Header Positions")
     self.flip_sign_positions_template = pd.read_excel(FIXTURE_WIDTH_TEMPLATE, "Flip Sign Positions")
     self.custom_entity_data = self.ps_data_provider.get_custom_entities(1005)
     self.ignore_stacking = False
     self.facings_field = 'facings' if not self.ignore_stacking else 'facings_ign_stack'
     self.kpi_new_static_data = self.common.get_new_kpi_static_data()
     try:
         self.mpis = self.match_product_in_scene.merge(self.products, on='product_fk', suffixes=['', '_p']) \
                     .merge(self.scene_info, on='scene_fk', suffixes=['', '_s']) \
                       .merge(self.template_info, on='template_fk', suffixes=['', '_t'])
     except KeyError:
         Log.warning('MPIS cannot be generated!')
         return
     self.adp = AltriaDataProvider(self.data_provider)
     self.active_kpis = self._get_active_kpis()
     self.external_targets = self.ps_data_provider.get_kpi_external_targets()
     self.survey_dot_com_collected_this_session = self._get_survey_dot_com_collected_value()
     self._add_smart_attributes_to_mpis()
     self.scene_graphs = {}
     self.excessive_flipsigns = False
     self.incorrect_tags_in_pos_areas = []
예제 #15
0
 def __init__(self, data_provider, output, common_db2):
     self.output = output
     self.data_provider = data_provider
     # self.common_db = Common(self.data_provider, SUB_PROJECT)
     # self.common_db2 = common_db2
     self.common_db2 = CommonV3(self.data_provider)
     self.common_scene = CommonV2(self.data_provider)
     self.project_name = self.data_provider.project_name
     self.session_uid = self.data_provider.session_uid
     self.manufacturer_fk = 1
     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.scif = self.data_provider[Data.SCENE_ITEM_FACTS]
     self.scif = self.scif[~(self.scif['product_type'] == 'Irrelevant')]
     self.sw_scenes = self.get_sw_scenes() # we don't need to check scenes without United products
     self.survey = Survey(self.data_provider, self.output)
     self.sos = SOS(self.data_provider, self.output)
     self.results = self.data_provider[Data.SCENE_KPI_RESULTS]
     self.templates = {}
     self.region = self.store_info['region_name'].iloc[0]
     self.store_type = self.store_info['store_type'].iloc[0]
     self.program = self.store_info['additional_attribute_3'].iloc[0]
     self.sales_center = self.store_info['additional_attribute_5'].iloc[0]
     if self.store_type in STORE_TYPES: #####
         self.store_type = STORE_TYPES[self.store_type] ####
     self.store_attr = self.store_info['additional_attribute_3'].iloc[0]
     # self.kpi_static_data = self.common_db.get_kpi_static_data()
     self.total_score = 0
     self.sub_scores = defaultdict(int)
     self.sub_totals = defaultdict(int)
     self.ignore_stacking = False
     self.facings_field = 'facings' if not self.ignore_stacking else 'facings_ign_stack'
     for sheet in Const.SHEETS_CMA:
         self.templates[sheet] = pd.read_excel(TEMPLATE_PATH, sheetname=sheet).fillna('')
     self.tools = Shared(self.data_provider, self.output)
예제 #16
0
 def __init__(self, data_provider, output):
     self.data_provider = data_provider
     self.commonV2 = CommonV2(self.data_provider)
     self.rds_conn = PSProjectConnector(self.data_provider.project_name, DbUsers.CalculationEng)
     self.store_assortment = PSAssortmentDataProvider(self.data_provider).execute(policy_name=None)
     self.output = output
     self.kpi_static_data = self.get_kpi_static_data()
     self.store_id = self.data_provider[Data.STORE_FK]
     self.own_manufacturer_fk = 12
     self.store_info = self.get_store_info(self.store_id)
     self.scif = self.data_provider[Data.SCENE_ITEM_FACTS]
     self.all_templates = self.data_provider[Data.ALL_TEMPLATES]
     self.common = Common(self.data_provider)
     self.scene_info = self.data_provider[Data.SCENES_INFO]
     self.diageo_generator = DIAGEOGenerator(self.data_provider, self.output, self.common)
     self.template_handler = TemplateHandler(self.data_provider.project_name)
     self.template_path = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'Data')
     self.template_path = os.path.join(self.template_path, "Template.xlsx")
     self.kpi_template_data = parse_template(self.template_path, sheet_name='KPI')
     self.store_info = self.data_provider[Data.STORE_INFO]
     self.current_date = datetime.now()
예제 #17
0
 def __init__(self, data_provider, output):
     self.output = output
     self.data_provider = data_provider
     self.common = Common(self.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.scif = self.data_provider[Data.SCENE_ITEM_FACTS]
     self.rds_conn = PSProjectConnector(self.project_name,
                                        DbUsers.CalculationEng)
     self.kpi_static_data = self.common.get_kpi_static_data()
     self.kpi_results_queries = []
     kpi_path = os.path.dirname(os.path.realpath(__file__))
     base_file = os.path.basename(kpi_path)
     kpi_info = pd.read_excel(os.path.join(kpi_path[:-len(base_file)],
                                           'Data', 'Template.xlsx'),
                              sheet_name="KPI")
     file_template = pd.read_excel(os.path.join(kpi_path[:-len(base_file)],
                                                'Data', 'Template.xlsx'),
                                   sheet_name="Template")
     self.kpi_template_info = pd.DataFrame(
         kpi_info)  # contains the kpis + ean codes
     self.kpi_metadata = self.data_provider.kpi  # information about kpis such as (presentation order)
     self.template_info = self.data_provider.templates  # static data on templates
     self.kpi_template = pd.DataFrame(
         file_template)  # relevant template for kpis
     # common for new tables
     self.commonV2 = CommonV2(self.data_provider)
     self.kpi_new_static_data = self.commonV2.get_new_kpi_static_data()
     self.manufacturer_fk = None if self.data_provider[Data.OWN_MANUFACTURER]['param_value'].iloc[0] is None else \
         int(self.data_provider[Data.OWN_MANUFACTURER]['param_value'].iloc[0])
예제 #18
0
    def __init__(self, data_provider, output):
        self.output = output
        self.data_provider = data_provider
        self.common = CommonV2  # remove later
        self.common_v2 = CommonV2(self.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.scif = self.data_provider[Data.SCENE_ITEM_FACTS]
        self.rds_conn = PSProjectConnector(self.project_name, DbUsers.CalculationEng)
        self.kpi_results_queries = []
        self.ps_data_provider = PsDataProvider(self.data_provider, self.output)
        self.survey = Survey(self.data_provider, output=self.output, ps_data_provider=self.ps_data_provider,
                             common=self.common_v2)
        self.store_sos_policies = self.ps_data_provider.get_store_policies()
        self.labels = self.ps_data_provider.get_labels()
        self.store_info = self.data_provider[Data.STORE_INFO]
        self.store_info = self.ps_data_provider.get_ps_store_info(self.store_info)
        self.country = self.store_info['country'].iloc[0]
        self.current_date = datetime.now()
        self.extra_spaces_template = pd.read_excel(Const.EXTRA_SPACES_RELEVANT_SUB_CATEGORIES_PATH)
        self.store_targets = pd.read_excel(Const.STORE_TARGETS_PATH)
        self.sub_category_weight = pd.read_excel(Const.SUB_CATEGORY_TARGET_PATH, sheetname='category_score')
        self.kpi_weights = pd.read_excel(Const.SUB_CATEGORY_TARGET_PATH, sheetname='max_weight')
        self.targets = self.ps_data_provider.get_kpi_external_targets()
        self.store_assortment = PSAssortmentDataProvider(
            self.data_provider).execute(policy_name=None)
        self.supervisor_target = self.get_supervisor_target()
        try:
            self.sub_category_assortment = pd.merge(self.store_assortment,
                                                    self.all_products.loc[:, ['product_fk', 'sub_category',
                                                                              'sub_category_fk']],
                                                    how='left', on='product_fk')
            self.sub_category_assortment = \
                self.sub_category_assortment[~self.sub_category_assortment['assortment_name'].str.contains(
                    'ASSORTMENT')]
            self.sub_category_assortment = pd.merge(self.sub_category_assortment, self.sub_category_weight, how='left',
                                                    left_on='sub_category',
                                                    right_on='Category')


        except KeyError:
            self.sub_category_assortment = pd.DataFrame()
        self.update_score_sub_category_weights()
        try:
            self.store_assortment_without_powerskus = \
                self.store_assortment[self.store_assortment['assortment_name'].str.contains('ASSORTMENT')]
        except KeyError:
            self.store_assortment_without_powerskus = pd.DataFrame()

        self.adherence_results = pd.DataFrame(columns=['product_fk', 'trax_average',
                                                       'suggested_price', 'into_interval', 'min_target', 'max_target',
                                                       'percent_range'])
        self.extra_spaces_results = pd.DataFrame(
            columns=['sub_category_fk', 'template_fk', 'count'])

        self.powersku_scores = {}
        self.powersku_empty = {}

        self.powersku_bonus = {}
        self.powersku_price = {}
        self.powersku_sos = {}
예제 #19
0
 def __init__(self, data_provider, output):
     self.data_provider = data_provider
     self.output = output
     self.project_name = data_provider.project_name
     self.session_uid = self.data_provider.session_uid
     self.common = CommonV2(self.data_provider)
예제 #20
0
 def __init__(self, data_provider, output):
     self.data_provider = data_provider
     self.output = output
     self.common_v2 = CommonV2(self.data_provider)