Beispiel #1
0
            changed = False

            if not sa_comment:
                debug("  Comment isn't fetched yet. Saving it to DB...")
                sa_comment = Comment(post_id=post.id,
                                     lepra_comment_id=comment_id,
                                     author=author,
                                     youtube_url=urls[0],
                                     rating=rating,
                                     comment=text)
                session.add(sa_comment)
                session.commit()
            else:
                if sa_comment.rating != rating:
                    debug("  Comment's rating changed.")
                    sa_comment.rating = rating
                    changed = True

                if sa_comment.comment != text:
                    debug("  Comment's text changed.")
                    sa_comment.comment = text
                    changed = True

                if changed:
                    debug("  Saving changes to DB...")
                    session.commit()

            reddit_comment_text = REDDIT_COMMENT_SLUG.format(comment=text,
                                                             comment_url=lepra_comment_url,
                                                             rating=rating,
                                                             author_prefix=author_prefix,