diff options
| author | rr- | 2016-06-12 14:01:38 +0200 |
|---|---|---|
| committer | rr- | 2016-06-12 14:01:38 +0200 |
| commit | a67db59d99c00e3066818fdfffb3a965ea7f2843 (patch) | |
| tree | 7bc51d67f282a17eeb1a619ae9b516a8ef7565ee /server | |
| parent | 7e8a9a0948bb0f778eb162455276c2a806ece6ff (diff) | |
server/comments: fix serializing cached scores
Diffstat (limited to 'server')
| -rw-r--r-- | server/szurubooru/db/comment.py | 3 | ||||
| -rw-r--r-- | server/szurubooru/tests/api/test_comment_rating.py | 1 |
2 files changed, 2 insertions, 2 deletions
diff --git a/server/szurubooru/db/comment.py b/server/szurubooru/db/comment.py index a91f1fc..94f0125 100644 --- a/server/szurubooru/db/comment.py +++ b/server/szurubooru/db/comment.py @@ -35,7 +35,8 @@ class Comment(Base): @property def score(self): - return object_session(self) \ + from szurubooru.db import session + return session \ .query(func.sum(CommentScore.score)) \ .filter(CommentScore.comment_id == self.comment_id) \ .one()[0] or 0 diff --git a/server/szurubooru/tests/api/test_comment_rating.py b/server/szurubooru/tests/api/test_comment_rating.py index 6a8360a..ac0aa7f 100644 --- a/server/szurubooru/tests/api/test_comment_rating.py +++ b/server/szurubooru/tests/api/test_comment_rating.py @@ -33,7 +33,6 @@ def test_simple_rating(test_ctx, fake_datetime): test_ctx.context_factory(input={'score': 1}, user=user), comment.comment_id) assert 'text' in result - comment = db.session.query(db.Comment).one() assert db.session.query(db.CommentScore).count() == 1 assert comment is not None assert comment.score == 1 |