示例#1
0
def index(request):
    today = datetime.today()
    month_ago = today - timedelta(days=31)
    week_ago = today - timedelta(weeks=1)
    day_ago = today - timedelta(days=1)
    
    videos_st = get_model_statistics(Video, today, month_ago, week_ago, day_ago)

    tweet_st = get_model_statistics(TweeterShareStatistic, today, month_ago, week_ago, day_ago)
    
    fb_st = get_model_statistics(FBShareStatistic, today, month_ago, week_ago, day_ago)

    email_st = get_model_statistics(EmailShareStatistic, today, month_ago, week_ago, day_ago)
    
    context = {
        'subtitles_fetched_count': sub_fetch_total_counter.get(),
        'view_count': widget_views_total_counter.get(),
        'videos_with_captions': Video.objects.exclude(subtitlelanguage=None).count(),
        'all_videos': Video.objects.count(),
        'all_users': User.objects.count(),
        'translations_count': SubtitleLanguage.objects.filter(is_original=False).count(),
        'fineshed_translations': SubtitleLanguage.objects.filter(is_original=False, had_version=True).count(),
        'unfineshed_translations': SubtitleLanguage.objects.filter(is_original=False, had_version=False).count(),
        'all_comments': Comment.objects.count(),
        'videos_st': videos_st,
        'tweet_st': tweet_st,
        'fb_st': fb_st,
        'email_st': email_st        
    }
           
    return context
示例#2
0
文件: views.py 项目: exezaid/mirosubs
def index(request):
    today = datetime.today()
    month_ago = today - timedelta(days=31)
    week_ago = today - timedelta(weeks=1)
    day_ago = today - timedelta(days=1)

    videos_st = get_model_statistics(Video, today, month_ago, week_ago,
                                     day_ago)

    tweet_st = get_model_statistics(TweeterShareStatistic, today, month_ago,
                                    week_ago, day_ago)

    fb_st = get_model_statistics(FBShareStatistic, today, month_ago, week_ago,
                                 day_ago)

    email_st = get_model_statistics(EmailShareStatistic, today, month_ago,
                                    week_ago, day_ago)

    context = {
        'subtitles_fetched_count':
        sub_fetch_total_counter.get(),
        'view_count':
        widget_views_total_counter.get(),
        'videos_with_captions':
        Video.objects.exclude(subtitlelanguage=None).count(),
        'all_videos':
        Video.objects.count(),
        'all_users':
        User.objects.count(),
        'translations_count':
        SubtitleLanguage.objects.filter(is_original=False).count(),
        'fineshed_translations':
        SubtitleLanguage.objects.filter(is_original=False,
                                        had_version=True).count(),
        'unfineshed_translations':
        SubtitleLanguage.objects.filter(is_original=False,
                                        had_version=False).count(),
        'all_comments':
        Comment.objects.count(),
        'videos_st':
        videos_st,
        'tweet_st':
        tweet_st,
        'fb_st':
        fb_st,
        'email_st':
        email_st
    }

    return context
示例#3
0
def index(request):
    today = datetime.today()
    month_ago = today - timedelta(days=31)
    week_ago = today - timedelta(weeks=1)
    day_ago = today - timedelta(days=1)

    videos_st = {}
    videos_st["total"] = Video.objects.count()
    videos_st["month"] = Video.objects.filter(created__range=(month_ago, today)).count()
    videos_st["week"] = Video.objects.filter(created__range=(week_ago, today)).count()
    videos_st["day"] = Video.objects.filter(created__range=(day_ago, today)).count()

    tweet_st = {}
    tweet_st["total"] = TweeterShareStatistic.objects.count()
    tweet_st["month"] = TweeterShareStatistic.objects.filter(created__range=(month_ago, today)).count()
    tweet_st["week"] = TweeterShareStatistic.objects.filter(created__range=(week_ago, today)).count()
    tweet_st["day"] = TweeterShareStatistic.objects.filter(created__range=(day_ago, today)).count()

    fb_st = {}
    fb_st["total"] = FBShareStatistic.objects.count()
    fb_st["month"] = FBShareStatistic.objects.filter(created__range=(month_ago, today)).count()
    fb_st["week"] = FBShareStatistic.objects.filter(created__range=(week_ago, today)).count()
    fb_st["day"] = FBShareStatistic.objects.filter(created__range=(day_ago, today)).count()

    email_st = {}
    email_st["total"] = EmailShareStatistic.objects.count()
    email_st["month"] = EmailShareStatistic.objects.filter(created__range=(month_ago, today)).count()
    email_st["week"] = EmailShareStatistic.objects.filter(created__range=(week_ago, today)).count()
    email_st["day"] = EmailShareStatistic.objects.filter(created__range=(day_ago, today)).count()

    context = {
        "subtitles_fetched_count": sub_fetch_total_counter.get(),
        "view_count": widget_views_total_counter.get(),
        "videos_with_captions": Video.objects.exclude(subtitlelanguage=None).count(),
        "all_videos": Video.objects.count(),
        "all_users": User.objects.count(),
        "translations_count": SubtitleLanguage.objects.filter(is_original=False).count(),
        "fineshed_translations": SubtitleLanguage.objects.filter(is_original=False, was_complete=True).count(),
        "unfineshed_translations": SubtitleLanguage.objects.filter(is_original=False, was_complete=False).count(),
        "all_comments": Comment.objects.count(),
        "videos_st": videos_st,
        "tweet_st": tweet_st,
        "fb_st": fb_st,
        "email_st": email_st,
    }

    return context
示例#4
0
def index(request):
    today = datetime.today()
    month_ago = today - timedelta(days=31)
    week_ago = today - timedelta(weeks=1)
    day_ago = today - timedelta(days=1)
    
    videos_st = {}
    videos_st['total'] = Video.objects.count()
    videos_st['month'] = Video.objects.filter(created__range=(month_ago, today)).count()
    videos_st['week'] = Video.objects.filter(created__range=(week_ago, today)).count()
    videos_st['day'] = Video.objects.filter(created__range=(day_ago, today)).count()

    tweet_st = {}
    tweet_st['total'] = TweeterShareStatistic.objects.count()
    tweet_st['month'] = TweeterShareStatistic.objects.filter(created__range=(month_ago, today)).count()
    tweet_st['week'] = TweeterShareStatistic.objects.filter(created__range=(week_ago, today)).count()
    tweet_st['day'] = TweeterShareStatistic.objects.filter(created__range=(day_ago, today)).count()
    
    fb_st = {}
    fb_st['total'] = FBShareStatistic.objects.count()
    fb_st['month'] = FBShareStatistic.objects.filter(created__range=(month_ago, today)).count()
    fb_st['week'] = FBShareStatistic.objects.filter(created__range=(week_ago, today)).count()
    fb_st['day'] = FBShareStatistic.objects.filter(created__range=(day_ago, today)).count()
    
    email_st = {}
    email_st['total'] = EmailShareStatistic.objects.count()
    email_st['month'] = EmailShareStatistic.objects.filter(created__range=(month_ago, today)).count()
    email_st['week'] = EmailShareStatistic.objects.filter(created__range=(week_ago, today)).count()
    email_st['day'] = EmailShareStatistic.objects.filter(created__range=(day_ago, today)).count()

    context = {
        'subtitles_fetched_count': sub_fetch_total_counter.get(),
        'view_count': widget_views_total_counter.get(),
        'videos_with_captions': Video.objects.exclude(subtitlelanguage=None).count(),
        'all_videos': Video.objects.count(),
        'all_users': User.objects.count(),
        'translations_count': SubtitleLanguage.objects.filter(is_original=False).count(),
        'fineshed_translations': SubtitleLanguage.objects.filter(is_original=False, had_version=True).count(),
        'unfineshed_translations': SubtitleLanguage.objects.filter(is_original=False, had_version=False).count(),
        'all_comments': Comment.objects.count(),
        'videos_st': videos_st,
        'tweet_st': tweet_st,
        'fb_st': fb_st,
        'email_st': email_st        
    }
           
    return context
示例#5
0
def index(request):
    today = datetime.today()
    month_ago = today - timedelta(days=31)
    week_ago = today - timedelta(weeks=1)
    day_ago = today - timedelta(days=1)

    videos_st = {}
    videos_st['total'] = Video.objects.count()
    videos_st['month'] = Video.objects.filter(created__range=(month_ago,
                                                              today)).count()
    videos_st['week'] = Video.objects.filter(created__range=(week_ago,
                                                             today)).count()
    videos_st['day'] = Video.objects.filter(created__range=(day_ago,
                                                            today)).count()

    tweet_st = {}
    tweet_st['total'] = TweeterShareStatistic.objects.count()
    tweet_st['month'] = TweeterShareStatistic.objects.filter(
        created__range=(month_ago, today)).count()
    tweet_st['week'] = TweeterShareStatistic.objects.filter(
        created__range=(week_ago, today)).count()
    tweet_st['day'] = TweeterShareStatistic.objects.filter(
        created__range=(day_ago, today)).count()

    fb_st = {}
    fb_st['total'] = FBShareStatistic.objects.count()
    fb_st['month'] = FBShareStatistic.objects.filter(
        created__range=(month_ago, today)).count()
    fb_st['week'] = FBShareStatistic.objects.filter(
        created__range=(week_ago, today)).count()
    fb_st['day'] = FBShareStatistic.objects.filter(
        created__range=(day_ago, today)).count()

    email_st = {}
    email_st['total'] = EmailShareStatistic.objects.count()
    email_st['month'] = EmailShareStatistic.objects.filter(
        created__range=(month_ago, today)).count()
    email_st['week'] = EmailShareStatistic.objects.filter(
        created__range=(week_ago, today)).count()
    email_st['day'] = EmailShareStatistic.objects.filter(
        created__range=(day_ago, today)).count()

    context = {
        'subtitles_fetched_count':
        sub_fetch_total_counter.get(),
        'view_count':
        widget_views_total_counter.get(),
        'videos_with_captions':
        Video.objects.exclude(subtitlelanguage=None).count(),
        'all_videos':
        Video.objects.count(),
        'all_users':
        User.objects.count(),
        'translations_count':
        SubtitleLanguage.objects.filter(is_original=False).count(),
        'fineshed_translations':
        SubtitleLanguage.objects.filter(is_original=False,
                                        had_version=True).count(),
        'unfineshed_translations':
        SubtitleLanguage.objects.filter(is_original=False,
                                        had_version=False).count(),
        'all_comments':
        Comment.objects.count(),
        'videos_st':
        videos_st,
        'tweet_st':
        tweet_st,
        'fb_st':
        fb_st,
        'email_st':
        email_st
    }

    return context