def init(self): start_time_sec = int(round(time.time())) print('Content Creation Status Report::Start') result_loc = self.data_store_location.joinpath('content_creation') result_loc.mkdir(exist_ok=True) execution_date = datetime.strptime(self.execution_date, "%d/%m/%Y") get_tenant_info(result_loc_=result_loc, org_search_=self.org_search, date_=execution_date) get_content_model(result_loc_=result_loc, druid_=self.druid_hostname, date_=execution_date, status_=['Live', 'Review', 'Draft', 'Unlisted']) self.generate_report(result_loc, execution_date) print('Content Creation Status Report::Completed') end_time_sec = int(round(time.time())) time_taken = end_time_sec - start_time_sec metrics = [{ 'metric': 'timeTakenSecs', 'value': time_taken }, { 'metric': 'date', 'value': execution_date.strftime('%Y-%m-%d') }] push_metric_event(metrics, 'Content Creation Status')
def init(self): start_time_sec = int(round(time.time())) print("GPS::Start") execution_date_ = datetime.strptime(self.execution_date, "%d/%m/%Y") self.data_store_location.joinpath( 'textbook_reports', execution_date_.strftime('%Y-%m-%d')).mkdir(exist_ok=True) get_scan_counts( result_loc_=self.data_store_location.joinpath('textbook_reports'), druid_=self.druid_hostname, date_=execution_date_) get_tenant_info( result_loc_=self.data_store_location.joinpath('textbook_reports'), org_search_=self.org_search, date_=execution_date_) self.get_tbs() self.generate_report() print("GPS::End") end_time_sec = int(round(time.time())) time_taken = end_time_sec - start_time_sec metrics = [{ "metric": "timeTakenSecs", "value": time_taken }, { "metric": "date", "value": execution_date_.strftime("%Y-%m-%d") }] push_metric_event(metrics, "ECG Learning")
def init(self): start_time_sec = int(round(time.time())) print("Content Consumption Report::Start") self.data_store_location = Path(self.data_store_location) org_search = self.org_search druid = self.druid_hostname druid_rollup = self.druid_rollup_hostname content_search = self.content_search execution_date = datetime.strptime(self.execution_date, "%d/%m/%Y") result_loc = self.data_store_location.joinpath('content_plays') result_loc.parent.joinpath('portal_dashboards').mkdir(exist_ok=True) result_loc.parent.joinpath('config').mkdir(exist_ok=True) get_data_from_blob( result_loc.parent.joinpath('config', 'diksha_config.json')) with open(result_loc.parent.joinpath('config', 'diksha_config.json'), 'r') as f: self.config = json.loads(f.read()) get_tenant_info(result_loc_=result_loc, org_search_=org_search, date_=execution_date) print("Success::Tenant info") get_content_model(result_loc_=result_loc, druid_=druid_rollup, date_=execution_date, config_=self.config, version_='v2') print("Success::content model snapshot") get_tb_content_mapping(result_loc_=result_loc, date_=execution_date, content_search_=content_search) print("Success::TB Content Map") self.get_weekly_report(result_loc_=result_loc, druid_rollup_=druid_rollup, date_=execution_date, config=self.config) print("Success::Weekly Conent Consumption") self.get_overall_report(result_loc_=result_loc, druid_rollup_=druid_rollup, date_=execution_date, config=self.config) print("Success::Overall Conent Consumption") self.get_last_week_report(result_loc_=result_loc, date_=execution_date, num_weeks=6) print("Success:::Last 6 weeks") shutil.rmtree(result_loc) print("Content Consumption Report::Completed") end_time_sec = int(round(time.time())) time_taken = end_time_sec - start_time_sec metrics = [{ "metric": "timeTakenSecs", "value": time_taken }, { "metric": "date", "value": execution_date.strftime("%Y-%m-%d") }] push_metric_event(metrics, "Content Consumption Metrics")
def init(self): start_time_sec = int(round(time.time())) print("Content Consumption Report::Start") self.data_store_location = Path(self.data_store_location) org_search = self.org_search druid = self.druid_hostname cassandra = self.cassandra_host keyspace = self.keyspace_prefix + 'content_db' execution_date = datetime.strptime(self.execution_date, "%d/%m/%Y") result_loc = self.data_store_location.joinpath('content_plays') result_loc.parent.joinpath('portal_dashboards').mkdir(exist_ok=True) result_loc.parent.joinpath('config').mkdir(exist_ok=True) get_data_from_blob( result_loc.parent.joinpath('config', 'diksha_config.json')) with open(result_loc.parent.joinpath('config', 'diksha_config.json'), 'r') as f: self.config = json.loads(f.read()) get_tenant_info(result_loc_=result_loc, org_search_=org_search, date_=execution_date) get_content_model(result_loc_=result_loc, druid_=druid, date_=execution_date) self.define_keyspace(cassandra_=cassandra, keyspace_=keyspace) for i in range(7): analysis_date = execution_date - timedelta(days=i) get_content_plays(result_loc_=result_loc, date_=analysis_date, druid_=druid) self.insert_data_to_cassandra(result_loc_=result_loc, date_=analysis_date, cassandra_=cassandra, keyspace_=keyspace) self.get_weekly_plays(result_loc_=result_loc, date_=execution_date, cassandra_=cassandra, keyspace_=keyspace) print("Content Consumption Report::Completed") end_time_sec = int(round(time.time())) time_taken = end_time_sec - start_time_sec metrics = [{ "metric": "timeTakenSecs", "value": time_taken }, { "metric": "date", "value": execution_date.strftime("%Y-%m-%d") }] push_metric_event(metrics, "Content Consumption Metrics")
def init(self): start_time_sec = int(round(time.time())) self.start_time = datetime.now() print("Started at: ", self.start_time.strftime('%Y-%m-%d %H:%M:%S')) end_date_ = datetime.strptime(self.execution_date, "%d/%m/%Y") self.data_store_location.joinpath('textbook_reports').mkdir( exist_ok=True) self.data_store_location.joinpath( 'textbook_reports', end_date_.strftime('%Y-%m-%d')).mkdir(exist_ok=True) self.data_store_location.joinpath('portal_dashboards').mkdir( exist_ok=True) get_tenant_info( result_loc_=self.data_store_location.joinpath('textbook_reports'), org_search_=self.org_search, date_=end_date_) # # TODO: SB-15177 store scan counts in cassandra get_scan_counts( result_loc_=self.data_store_location.joinpath('textbook_reports'), druid_=self.druid_hostname, date_=end_date_) self.backend_grade = pd.DataFrame( sorted_grades.init()).set_index('grade') self.generate_reports(result_loc_=self.data_store_location, content_search_=self.content_search, content_hierarchy_=self.content_hierarchy, date_=end_date_) end_time = datetime.now() print("Ended at: ", end_time.strftime('%Y-%m-%d %H:%M:%S')) print("Time taken: ", str(end_time - self.start_time)) end_time_sec = int(round(time.time())) time_taken = end_time_sec - start_time_sec metrics = [{ "metric": "timeTakenSecs", "value": time_taken }, { "metric": "date", "value": end_date_.strftime("%Y-%m-%d") }] push_metric_event(metrics, "ETB Creation Metrics")
def init(self): start_time_sec = int(round(time.time())) print('[START] Landing Page!') self.current_time = date.today() get_tenant_info( result_loc_=self.data_store_location.joinpath('textbook_reports'), org_search_=self.org_search, date_=self.current_time) self.generate_report() print('[SUCCESS] Landing Page!') end_time_sec = int(round(time.time())) time_taken = end_time_sec - start_time_sec metrics = [{ "metric": "timeTakenSecs", "value": time_taken }, { "metric": "date", "value": self.current_time.strftime("%Y-%m-%d") }] push_metric_event(metrics, "Landing Page")
def init(self): start_time_sec = int(round(time.time())) print("START:CMO Dashboard") data_store_location = self.data_store_location.joinpath('portal_dashboards') data_store_location.mkdir(exist_ok=True) analysis_date = datetime.strptime(self.execution_date, "%d/%m/%Y") data_store_location.joinpath('public').mkdir(exist_ok=True) get_data_from_blob(data_store_location.joinpath('overall', 'daily_metrics.csv')) self.data_wrangling(result_loc_=data_store_location.joinpath('overall', 'daily_metrics.csv'), date_=analysis_date) create_json(data_store_location.joinpath('public', 'cmo_dashboard.csv'), last_update=True) post_data_to_blob(data_store_location.joinpath('public', 'cmo_dashboard.csv')) get_tenant_info(result_loc_=data_store_location.parent.joinpath('textbook_reports'), org_search_=self.org_search, date_=analysis_date) board_slug = pd.read_csv( data_store_location.parent.joinpath('textbook_reports', analysis_date.strftime('%Y-%m-%d'), 'tenant_info.csv')) slug_list = board_slug['slug'].unique().tolist() for slug in slug_list: try: get_data_from_blob(result_loc_=data_store_location.joinpath(slug, 'daily_metrics.csv')) self.data_wrangling(result_loc_=data_store_location.joinpath(slug, 'daily_metrics.csv'), date_=analysis_date) create_json(read_loc_=data_store_location.joinpath(slug, 'cmo_dashboard.csv'), last_update=True) post_data_to_blob(result_loc_=data_store_location.joinpath(slug, 'cmo_dashboard.csv')) except: pass print("END:CMO Dashboard") end_time_sec = int(round(time.time())) time_taken = end_time_sec - start_time_sec metrics = [ { "metric": "timeTakenSecs", "value": time_taken }, { "metric": "date", "value": analysis_date.strftime("%Y-%m-%d") } ] push_metric_event(metrics, "CMO Dashboard")
def init(self): start_time_sec = int(round(time.time())) print("START:Content Creation") result_loc = self.data_store_location.joinpath('content_creation') execution_date = datetime.strptime(self.execution_date, "%d/%m/%Y") get_tenant_info(result_loc_=result_loc, org_search_=self.org_search, date_=execution_date) self.weekly_creation(result_loc_=result_loc, date_=execution_date, content_search_=self.content_search) self.overall_creation(result_loc_=result_loc, date_=execution_date, content_search_=self.content_search) self.combine_creation_reports(result_loc_=result_loc, date_=execution_date) print("END:Content Creation") end_time_sec = int(round(time.time())) time_taken = end_time_sec - start_time_sec metrics = [ { "metric": "timeTakenSecs", "value": time_taken }, { "metric": "date", "value": execution_date.strftime("%Y-%m-%d") } ] push_metric_event(metrics, "Content Creation")
def init(self): start_time_sec = int(round(time.time())) start_time = datetime.now() print("Started at: ", start_time.strftime('%Y-%m-%d %H:%M:%S')) findspark.init() execution_date = datetime.strptime(self.execution_date, "%d/%m/%Y") analysis_date = execution_date - timedelta(1) self.data_store_location.joinpath('tb_metadata').mkdir(exist_ok=True) self.data_store_location.joinpath('play').mkdir(exist_ok=True) self.data_store_location.joinpath('downloads').mkdir(exist_ok=True) self.data_store_location.joinpath('dialcode_scans').mkdir( exist_ok=True) self.data_store_location.joinpath('portal_dashboards').mkdir( exist_ok=True) self.data_store_location.joinpath('config').mkdir(exist_ok=True) get_data_from_blob( self.data_store_location.joinpath('config', 'diksha_config.json')) with open( self.data_store_location.joinpath('config', 'diksha_config.json'), 'r') as f: self.config = json.loads(f.read()) get_textbook_snapshot( result_loc_=self.data_store_location.joinpath('tb_metadata'), content_search_=self.content_search, content_hierarchy_=self.content_hierarchy, date_=analysis_date) print('[Success] Textbook Snapshot') get_tenant_info( result_loc_=self.data_store_location.joinpath('textbook_reports'), org_search_=self.org_search, date_=analysis_date) print('[Success] Tenant Info') self.app_and_plays( result_loc_=self.data_store_location.joinpath('play'), date_=analysis_date) print('[Success] App and Plays') self.dialscans( result_loc_=self.data_store_location.joinpath('dialcode_scans'), date_=analysis_date) print('[Success] DIAL Scans') self.downloads( result_loc_=self.data_store_location.joinpath('downloads'), date_=analysis_date) print('[Success] Downloads') self.daily_metrics(read_loc_=self.data_store_location, date_=analysis_date) print('[Success] Daily metrics') end_time = datetime.now() print("Ended at: ", end_time.strftime('%Y-%m-%d %H:%M:%S')) print("Time taken: ", str(end_time - start_time)) end_time_sec = int(round(time.time())) time_taken = end_time_sec - start_time_sec metrics = [{ "metric": "timeTakenSecs", "value": time_taken }, { "metric": "date", "value": execution_date.strftime("%Y-%m-%d") }] push_metric_event(metrics, "Consumption Metrics")