コード例 #1
0
ファイル: DataSource.py プロジェクト: niczy/nich01as-us
def _populate_video_counters(videos):
    if not isinstance(videos, types.ListType):
        videos = [videos]
    counters = []
    cnt_to_video = {}
    for video in videos:
        counters_map = VideoModels.counters_map(video)
        for (k, v) in counters_map.iteritems():
            counters.append(k)
            cnt_to_video[k] = video
    results = fastcounter.get_counts(counters)
    for i in xrange(0, len(counters)):
        cntr = counters[i]
        video = cnt_to_video[cntr]
        counters_map = VideoModels.counters_map(video)
        video[counters_map[cntr]] = results[i]
コード例 #2
0
ファイル: DataSource.py プロジェクト: niczy/nich01as-us
def _score_videos(videos):
    for v in videos:
        v["final_score"] = VideoModels.score(v)
    return sorted(videos, key=lambda video: -video["final_score"])