Beispiel #1
0
 def save(cls, thread):
     dt = datestr_to_datetime(thread['createdAt'])
     thread['createdAt'] = dt
     result = cls.format(thread)
     score = dt.strftime('%s.%m')
     threads.add(result, score)
     threads.add_to_set(result['id'], thread['posts'], _key='posts')
     return result
Beispiel #2
0
 def save(cls, thread):
     dt = datestr_to_datetime(thread['createdAt'])
     thread['createdAt'] = dt
     result = cls.format(thread)
     score = dt.strftime('%s.%m')
     threads.add(result, score)
     threads.add_to_set(result['id'], thread['posts'], _key='posts')
     return result
Beispiel #3
0
    def list_by_author(cls, author_id, offset=0, limit=100):
        assert author_id == session['auth']['user_id']
        result = threads.list(author_id=author_id, offset=offset, limit=limit)
        if result is None:
            result = []
            for thread in api_call(disqusapi.users.listActiveThreads, forum=app.config['DISQUS_FORUM'], method='GET'):
                result.append(Thread.save(thread))
                score = thread['createdAt'].strftime('%s.%m')
                threads.add_to_set(thread['id'], score, author_id=author_id)
            result.reverse()

        return result
Beispiel #4
0
    def list_by_author(cls, author_id, offset=0, limit=100):
        assert author_id == session['auth']['user_id']
        result = threads.list(author_id=author_id, offset=offset, limit=limit)
        if result is None:
            result = []
            for thread in api_call(disqusapi.users.listActiveThreads,
                                   forum=app.config['DISQUS_FORUM'],
                                   method='GET'):
                result.append(Thread.save(thread))
                score = thread['createdAt'].strftime('%s.%m')
                threads.add_to_set(thread['id'], score, author_id=author_id)
            result.reverse()

        return result
Beispiel #5
0
    def save(cls, post, incr_posts=True):
        dt = datestr_to_datetime(post['createdAt'])
        post['createdAt'] = dt
        result = cls.format(post)
        score = dt.strftime('%s.%m')

        posts.add(result, score, thread_id=post['thread'])

        if incr_posts:
            threads.incr_counter(post['thread'], 'posts', 1)
            threads.incr_in_set(post['thread'], 1, _key='posts')
            threads.add_to_set(post['thread'], score)

        user = User.save(post['author'])
        users.add_to_set(user['id'], score, thread_id=post['thread'])
        threads.add_to_set(post['thread'], score)
        threads.add_to_set(post['thread'], score, author_id=post['author'])

        return result
Beispiel #6
0
    def save(cls, post, incr_posts=True):
        dt = datestr_to_datetime(post['createdAt'])
        post['createdAt'] = dt
        result = cls.format(post)
        score = dt.strftime('%s.%m')

        posts.add(result, score, thread_id=post['thread'])

        if incr_posts:
            threads.incr_counter(post['thread'], 'posts', 1)
            threads.incr_in_set(post['thread'], 1, _key='posts')
            threads.add_to_set(post['thread'], score)

        user = User.save(post['author'])
        users.add_to_set(user['id'], score, thread_id=post['thread'])
        threads.add_to_set(post['thread'], score)
        threads.add_to_set(post['thread'], score, author_id=post['author'])

        return result