示例#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
示例#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
示例#3
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
示例#4
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