def run(start): end = start + datetime.timedelta(days=7) topicIds = weeklyTopicsEnterTop10(start, end) print topicIds topic_list = [] for t in topicIds: to = topics.find_one({"_id": ObjectId(t)}, { 'name': 1, 'master': 1, "learning": 1 }) print to master = 1 if 'master' in to and 'status' in to['master'] and to[ 'master']['status'] == 'published' else 0 learning = 1 if 'learning' in to and 'status' in to['learning'] and to[ 'learning']['status'] == 'published' else 0 topic_list.append({ "_id": str(to['_id']), "name": to['name'], 'master': master, 'learning': learning }) print topic_list # print "---------- 新用户当天行为 ----------" # td.data_by_day(start, end) # print "---------- 新用户次周行为 ----------" # nw.next_week(start, end) print "---------- scene,", start.date(), "----------" sc.print_topic_scene(topic_list, start, end)
def run(start): end = start + datetime.timedelta(days=7) topicIds = weeklyTopicsEnterTop10(start, end) print topicIds topic_list = [] for t in topicIds: to = topics.find_one({"_id": ObjectId(t)}, {'name': 1, 'master': 1, "learning": 1}) print to master = 1 if 'master' in to and 'status' in to['master'] and to['master']['status'] == 'published' else 0 learning = 1 if 'learning' in to and 'status' in to['learning'] and to['learning']['status'] == 'published' else 0 topic_list.append({"_id": str(to['_id']), "name": to['name'], 'master': master, 'learning': learning}) print topic_list # print "---------- 新用户当天行为 ----------" # td.data_by_day(start, end) # print "---------- 新用户次周行为 ----------" # nw.next_week(start, end) print "---------- scene,", start.date(), "----------" sc.print_topic_scene(topic_list, start, end)
START_DATE = datetime.datetime(2016, 1, 17, 0) END_DATE = datetime.datetime(2016, 1, 24, 0) START_DATE_UTC = START_DATE - datetime.timedelta(hours=8) END_DATE_UTC = END_DATE - datetime.timedelta(hours=8) topicIds = weeklyTopicsEnterTop10(START_DATE_UTC, END_DATE_UTC) topic_list = [] for t in topicIds: to = topics.find_one({"_id": ObjectId(t)}, {'name': 1}) topic_list.append({"_id": str(to['_id']), "name": to['name']}) print "---------- that day ----------" td.data_by_day(START_DATE_UTC, END_DATE_UTC) print "---------- next week ----------" nw.next_week(START_DATE_UTC, END_DATE_UTC) print "---------- scene ----------" sc.print_topic_scene(topic_list, START_DATE_UTC, END_DATE_UTC) print "--------- time analysis ----------" ta.print_time_analysis(topic_list, START_DATE_UTC, END_DATE_UTC) e = time.time() print 'Total time: ', (e-s)/ 60, 'min'