Пример #1
0
def bulk_create_votes(rows, column, pdict, udict):
    for row in rows:
        row = {col: val for col, val in zip(column, row)}
        post = pdict[str(row['post_id'])]
        author = udict[row['author_id']]
        vtype = row['type']
        # Skip incomplete post/author information.
        if not (post and author) or not post.root:
            continue

        vote = Vote(post=post, author=author, type=vtype, uid=row['id'], date=row['date'])

        yield vote
    def gen_votes():
        logger.info("Transferring Votes")

        stream = zip(count(1), posts)
        stream = islice(stream, limit)

        elapsed, progress = timer_func()
        for index, vote in stream:
            progress(index, msg="votes")
            post = posts_map.get(str(vote.post_id))
            author = users_map.get(vote.author.email)
            # Skip existing votes and incomplete post/author information.
            if not (post and author) or not post.root:
                continue

            vote = Vote(post=post, author=author, type=vote.type, date=vote.date)
            yield vote
Пример #3
0
    def gen_votes():
        logger.info("Transferring Votes")
        posts_set = {post.uid: post for post in Post.objects.all()}
        users_set = {user.profile.uid: user for user in User.objects.all()}
        stream = zip(count(1), posts)
        stream = islice(stream, LIMIT)

        elapsed, progress = timer_func()

        for index, vote in stream:
            progress(index, msg="votes")
            post = posts_set.get(str(vote.post_id))
            author = users_set.get(str(vote.author_id))
            # Skip existing votes and incomplete post/author information.
            if not (post and author) or not post.root:
                continue

            vote = Vote(post=post, author=author, type=vote.type, uid=vote.id,
                        date=vote.date)
            yield vote