diff --git a/nyaa/forms.py b/nyaa/forms.py index 84334d5..af15003 100644 --- a/nyaa/forms.py +++ b/nyaa/forms.py @@ -11,8 +11,8 @@ from wtforms import (BooleanField, HiddenField, PasswordField, SelectField, Stri SubmitField, TextAreaField) from wtforms.validators import (DataRequired, Email, EqualTo, Length, Optional, Regexp, StopValidation, ValidationError) -from wtforms.widgets import Select as SelectWidget # For DisabledSelectField from wtforms.widgets import HTMLString # For DisabledSelectField +from wtforms.widgets import Select as SelectWidget # For DisabledSelectField from wtforms.widgets import html_params import dns.exception diff --git a/nyaa/models.py b/nyaa/models.py index e4bc387..24a9769 100644 --- a/nyaa/models.py +++ b/nyaa/models.py @@ -205,10 +205,8 @@ class TorrentBase(DeclarativeHelperBase): @classmethod def update_comment_count_db(cls, torrent_id): - comment_count = db.session.query(func.count(Comment.id)).filter_by( - torrent_id=torrent_id).first()[0] - db.session.query(cls).filter_by(id=torrent_id).update({'comment_count': comment_count}) - return comment_count + cls.query.filter_by(id=torrent_id).update({'comment_count': db.session.query( + func.count(Comment.id)).filter_by(torrent_id=torrent_id).as_scalar()}, False) @property def created_utc_timestamp(self):