mirror of
https://gitlab.com/SIGBUS/nyaa.git
synced 2024-12-22 09:19:59 +00:00
improve update_comment_count_db
This commit is contained in:
parent
93dffcd663
commit
8b809de8a2
|
@ -11,8 +11,8 @@ from wtforms import (BooleanField, HiddenField, PasswordField, SelectField, Stri
|
||||||
SubmitField, TextAreaField)
|
SubmitField, TextAreaField)
|
||||||
from wtforms.validators import (DataRequired, Email, EqualTo, Length, Optional, Regexp,
|
from wtforms.validators import (DataRequired, Email, EqualTo, Length, Optional, Regexp,
|
||||||
StopValidation, ValidationError)
|
StopValidation, ValidationError)
|
||||||
from wtforms.widgets import Select as SelectWidget # For DisabledSelectField
|
|
||||||
from wtforms.widgets import HTMLString # For DisabledSelectField
|
from wtforms.widgets import HTMLString # For DisabledSelectField
|
||||||
|
from wtforms.widgets import Select as SelectWidget # For DisabledSelectField
|
||||||
from wtforms.widgets import html_params
|
from wtforms.widgets import html_params
|
||||||
|
|
||||||
import dns.exception
|
import dns.exception
|
||||||
|
|
|
@ -205,10 +205,8 @@ class TorrentBase(DeclarativeHelperBase):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def update_comment_count_db(cls, torrent_id):
|
def update_comment_count_db(cls, torrent_id):
|
||||||
comment_count = db.session.query(func.count(Comment.id)).filter_by(
|
cls.query.filter_by(id=torrent_id).update({'comment_count': db.session.query(
|
||||||
torrent_id=torrent_id).first()[0]
|
func.count(Comment.id)).filter_by(torrent_id=torrent_id).as_scalar()}, False)
|
||||||
db.session.query(cls).filter_by(id=torrent_id).update({'comment_count': comment_count})
|
|
||||||
return comment_count
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def created_utc_timestamp(self):
|
def created_utc_timestamp(self):
|
||||||
|
|
Loading…
Reference in a new issue