Esempio n. 1
0
    def test_recently_popular(self):
        owner = db_utils.create_user()
        now = arrow.now()

        sub1 = db_utils.create_submission(owner,
                                          rating=ratings.GENERAL.code,
                                          unixtime=now -
                                          datetime.timedelta(days=6))
        sub2 = db_utils.create_submission(owner,
                                          rating=ratings.GENERAL.code,
                                          unixtime=now -
                                          datetime.timedelta(days=4))
        sub3 = db_utils.create_submission(owner,
                                          rating=ratings.GENERAL.code,
                                          unixtime=now -
                                          datetime.timedelta(days=2))
        sub4 = db_utils.create_submission(owner,
                                          rating=ratings.GENERAL.code,
                                          unixtime=now)
        tag = db_utils.create_tag(u'tag')

        for s in [sub1, sub2, sub3, sub4]:
            db_utils.create_submission_tag(tag, s)

        for i in range(100):
            favoriter = db_utils.create_user()
            db_utils.create_favorite(favoriter, submitid=sub2, unixtime=now)

        recently_popular = submission.select_recently_popular()

        self.assertEqual([item['submitid'] for item in recently_popular],
                         [sub2, sub4, sub3, sub1])
Esempio n. 2
0
 def GET(self):
     return define.webpage(self.user_id, 'etc/popular.html', [
         list(
             itertools.islice(
                 index.filter_submissions(
                     self.user_id,
                     submission.select_recently_popular(),
                     incidence_limit=1), 66))
     ])
Esempio n. 3
0
def popular_(request):
    return Response(
        define.webpage(request.userid, 'etc/popular.html', [
            list(
                itertools.islice(
                    index.filter_submissions(
                        request.userid,
                        submission.select_recently_popular(),
                        incidence_limit=1), 66))
        ]))
Esempio n. 4
0
def template_fields(userid):
    config = d.get_config(userid)
    rating = d.get_rating(userid)
    submissions = list(filter_submissions(userid, recent_submissions()))
    ret = partition_submissions(submissions)

    return ret + [
        # Recent site news update
        siteupdate.select(),
        # Recent critique submissions
        submission.select_list(userid, rating, 4, options=["critique"], config=config),
        # Currently streaming users
        profile.select_streaming(userid, rating, 4),
        # Recently popular submissions
        list(itertools.islice(filter_submissions(userid, submission.select_recently_popular(), incidence_limit=1), 11)),
    ]
Esempio n. 5
0
def template_fields(userid):
    config = d.get_config(userid)
    rating = d.get_rating(userid)
    submissions = list(filter_submissions(userid, recent_submissions()))
    ret = partition_submissions(submissions)

    return ret + [
        # Recent site news update
        siteupdate.select_last(),
        # Recent critique submissions
        submission.select_list(userid, rating, 4, options=["critique"], config=config),
        # Currently streaming users
        profile.select_streaming(userid, rating, 4),
        # Recently popular submissions
        list(itertools.islice(filter_submissions(userid, submission.select_recently_popular(), incidence_limit=1), 11)),
    ]
Esempio n. 6
0
    def test_recently_popular(self):
        owner = db_utils.create_user()
        now = arrow.now()

        sub1 = db_utils.create_submission(owner, rating=ratings.GENERAL.code, unixtime=now - datetime.timedelta(days=6))
        sub2 = db_utils.create_submission(owner, rating=ratings.GENERAL.code, unixtime=now - datetime.timedelta(days=4))
        sub3 = db_utils.create_submission(owner, rating=ratings.GENERAL.code, unixtime=now - datetime.timedelta(days=2))
        sub4 = db_utils.create_submission(owner, rating=ratings.GENERAL.code, unixtime=now)
        tag = db_utils.create_tag(u'tag')

        for s in [sub1, sub2, sub3, sub4]:
            db_utils.create_submission_tag(tag, s)

        for i in range(100):
            favoriter = db_utils.create_user()
            db_utils.create_favorite(favoriter, sub2, 's', unixtime=now)

        recently_popular = submission.select_recently_popular()

        self.assertEqual(
            [item['submitid'] for item in recently_popular],
            [sub2, sub4, sub3, sub1])
Esempio n. 7
0
def popular_(request):
    return Response(define.webpage(request.userid, 'etc/popular.html', [
        list(itertools.islice(
            index.filter_submissions(request.userid, submission.select_recently_popular(), incidence_limit=1), 66))
    ], title="Recently Popular"))
Esempio n. 8
0
 def GET(self):
     return define.webpage(self.user_id, 'etc/popular.html', [
         list(itertools.islice(
             index.filter_submissions(self.user_id, submission.select_recently_popular(), incidence_limit=1), 66))
     ])