Esempio n. 1
0
    def test_stats_for_user(self):
        g.user = h.MockUser('alice', 'fooconsumer')
        Annotation({
            'user': '******',
            'consumer': 'fooconsumer',
            'uri': 'a'
        }).save()
        Annotation({
            'user': '******',
            'consumer': 'fooconsumer',
            'uri': 'a'
        }).save()
        Annotation({
            'user': '******',
            'consumer': 'fooconsumer',
            'uri': 'b'
        }).save()
        Annotation({
            'user': '******',
            'consumer': 'fooconsumer',
            'uri': 'b'
        }).save()

        Annotation.es.conn.cluster.health(wait_for_status='yellow')

        stats = Annotation.stats_for_user(g.user)
        h.assert_equal(stats['num_annotations'], 3)
        h.assert_equal(stats['num_uris'], 2)
Esempio n. 2
0
    def test_stats_for_user(self):
        g.user = h.MockUser('alice', 'fooconsumer')
        Annotation({'user': '******', 'consumer': 'fooconsumer', 'uri': 'a'}).save()
        Annotation({'user': '******', 'consumer': 'fooconsumer', 'uri': 'a'}).save()
        Annotation({'user': '******', 'consumer': 'fooconsumer', 'uri': 'b'}).save()
        Annotation({'user': '******', 'consumer': 'fooconsumer', 'uri': 'b'}).save()

        Annotation.es.conn.cluster.health(wait_for_status='yellow')

        stats = Annotation.stats_for_user(g.user)
        h.assert_equal(stats['num_annotations'], 3)
        h.assert_equal(stats['num_uris'], 2)
Esempio n. 3
0
    def test_stats_for_user(self):
        g.user = h.MockUser('alice', 'fooconsumer')
        Annotation({'user': '******', 'consumer': 'fooconsumer', 'uri': 'a'}).save()
        Annotation({'user': '******', 'consumer': 'fooconsumer', 'uri': 'a'}).save()
        Annotation({'user': '******', 'consumer': 'fooconsumer', 'uri': 'b'}).save()
        Annotation({'user': '******', 'consumer': 'fooconsumer', 'uri': 'b'}).save()

        Annotation.es.conn.refresh(timesleep=0.01)

        stats = Annotation.stats_for_user(g.user)
        h.assert_equal(stats['num_annotations'], 3)
        h.assert_equal(stats['num_uris'], 2)
Esempio n. 4
0
def home_for_user(username):
    if username != g.user.username:
        abort(401)

    bookmarklet = render_template('bookmarklet.js', root=request.host_url.rstrip('/'))
    annotations = Annotation.search(user=g.user.id, limit=20)
    stats = Annotation.stats_for_user(g.user)

    return render_template('user/home.html',
                           user=g.user,
                           bookmarklet=bookmarklet,
                           annotations=annotations,
                           stats=stats)