Esempio n. 1
0
# -*- coding: utf-8 -*-

import sys
sys.path.append("..")

# 周前十知识点学习模块

from wheels import *
from wheels import dataset
from wheels import courseFilter
from wheels import userFilter
from wheels import getPercent

top10Topics = courseFilter.weeklyTopicsEnterTop10()
top10TopicsList = []
for i in range(10):
    top10TopicsList.append(str(top10Topics[i]))


# 计算周前10知识点的完成率函数
def completionRate(mEvent, dEvent, top10TopicsList):
    m = dataset.aggregateTopic(mEvent, top10TopicsList)
    mNum = len(m['user']) + len(m['device'])
    d = dataset.aggregateTopic(dEvent, top10TopicsList)
    dNum = len(d['user']) + len(d['device'])
    return getPercent.getPerNum(mNum, dNum)


# 学习模块总完成率
print("学习模块总完成率:")
print(completionRate("completeLearning", "startLearning", top10TopicsList))
Esempio n. 2
0
    pipeline = [
        {"$match": candidate_match},
        {"$match": {"user": {"$exists": True}}},
        {"$match": {"user": {"$in": multiple_users}}},
        {"$group": {"_id": None, "users": {"$addToSet": "$user"}}}
    ]
    round_2_num = list(events.aggregate(pipeline))
    if len(round_2_num) > 0:
        round_2_num = len(round_2_num[0]['users'])
    else:
        round_2_num = 0

    return round_1_num + round_2_num


# Get a nested list of videoIds and an eventkey returns a list of uvs
def get_video_times(video_list, event_key):
    event_match = {"eventKey": event_key, "eventValue.videoId": {"$in": [str(each) for each in video_list]}}
    return calc_uv(event_match)


# topic_id = [ObjectId("54c708798bac81fccbd4bb3c")]
topic_ids = cf.weeklyTopicsEnterTop10()
a = topic2video(topic_ids)
res = []
for each in a:
    res.append(get_video_times(each, 'startVideo'))
# res = get_video_times(a, "finishVideo")
print res
Esempio n. 3
0
# -*- coding: utf-8 -*-

import sys
sys.path.append("..")

# 周前十知识点 挑战

from wheels import *
from wheels import dataset
from wheels import courseFilter
from wheels import userFilter

top10Topics = courseFilter.weeklyTopicsEnterTop10()
top10TopicsList = []
for i in range(10):
    top10TopicsList.append(str(top10Topics[i]))

def clickAssess(top10TopicsList):
    pipeLine = [
        {"$match": {
            "eventKey": "clickExpVideo",
            "eventValue.topicId": {"$in": top10TopicsList}
        }},
        {"$group": {
            "_id": None,
            "users": {"$addToSet": top10TopicsList}
        }}
    ]
    return list(events.aggregate(pipeLine))

print("周前10知识点 点击挑战解析:")