def handle(self): user_ids = set() collector = self.get_container()['collector'] user_service = self.get_container()['user_service'] dates_ranges = DateHelper.split_period([self.option('from'), self.option('to')], int(self.option('step'))) self.line("Split to {} ranges".format(len(dates_ranges))) for dates_range in dates_ranges: self.line(" Collect {} - {} ...".format(dates_range[0], dates_range[1])) self.line("\n") user_ids |= collector.collect_referrer(dates_range, self.progress_bar()) self.line("\n") self.line("Get {} user ids\n".format(len(user_ids))) progress = self.progress_bar(len(user_ids)) referrer_service = self.get_container()['referrer_service'] first_referrers = referrer_service.get_first_referrer(list(user_ids)) for row in first_referrers: user_service.update_referrer(row['user_id'], row['referrer']) progress.advance() progress.finish() self.line("\nDone!")
def handle(self): collector = self.get_container()['collector'] dates_ranges = DateHelper.split_period( [self.option('from'), self.option('to')], int(self.option('step'))) self.line("Split to {} ranges".format(len(dates_ranges))) for dates_range in dates_ranges: self.line("Collect {} - {}...\n".format(dates_range[0], dates_range[1])) collector.collect_language(dates_range, self.progress_bar()) self.line("\n") self.line('Done!')
def handle(self): user_ids = set() collector = self.get_container()['collector'] dates_ranges = DateHelper.split_period( [self.option('from'), self.option('to')], int(self.option('step'))) self.line("Amount of periods - {}".format(len(dates_ranges))) for dates_range in dates_ranges: self.line("\nPeriod => {} - {}".format(dates_range[0], dates_range[1])) # collect sessions self.line("\nCollect sessions...") collector.collect_session(dates_range, self.progress_bar()) # collect scenes self.line("\nCollect scenes...") collector.collect_scene(dates_range, self.progress_bar()) # collect bands self.line("\nCollect bands...") collector.collect_band(dates_range, self.progress_bar()) # collect downloads self.line("\nCollect downloads...") collector.collect_download(dates_range, self.progress_bar()) # collect languages self.line("\nCollect languages...") collector.collect_language(dates_range, self.progress_bar()) # collect referrers self.line("\nCollect referrers...") user_ids |= collector.collect_referrer(dates_range, self.progress_bar()) self.line("\nGet {} user ids from referrer data".format(len(user_ids))) progress = self.progress_bar(len(user_ids)) referrer_service = self.get_container()['referrer_service'] first_referrers = referrer_service.get_first_referrer(list(user_ids)) user_service = self.get_container()['user_service'] for row in first_referrers: user_service.update_referrer(row['user_id'], row['referrer']) progress.advance() progress.finish() self.line("\nDone!")