🏦 Database Change: convert created utc to datetimez for notifications (#668)

This commit is contained in:
Viet Than 2023-08-02 21:35:05 -05:00 committed by GitHub
parent 34b328583c
commit e1075eb722
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 57 additions and 5 deletions

View file

@ -1,8 +1,8 @@
from sqlalchemy import *
from sqlalchemy.orm import relationship
from files.classes.base import CreatedBase
from files.classes.base import CreatedDateTimeBase
class Notification(CreatedBase):
class Notification(CreatedDateTimeBase):
__tablename__ = "notifications"
user_id = Column(Integer, ForeignKey("users.id"), primary_key=True)

View file

@ -30,7 +30,7 @@ def unread(v):
Comment.state_mod == StateMod.VISIBLE,
Comment.state_user_deleted_utc == None,
Comment.author_id != AUTOJANNY_ID,
).order_by(Notification.created_utc.desc()).all()
).order_by(Notification.created_datetimez.desc()).all()
for n, c in listing:
n.read = True
@ -52,7 +52,7 @@ def notifications_main(v: User):
Comment.state_mod == StateMod.VISIBLE,
Comment.state_user_deleted_utc == None,
Comment.author_id != AUTOJANNY_ID,
).order_by(Notification.created_utc.desc()))
).order_by(Notification.created_datetimez.desc()))
if not v.shadowbanned and v.admin_level < 3:
comments = comments.join(Comment.author).filter(User.shadowbanned == None)
@ -96,7 +96,7 @@ def notifications_posts(v: User):
notifications = (g.db.query(Notification, Comment)
.join(Comment, Notification.comment_id == Comment.id)
.filter(Notification.user_id == v.id, Comment.author_id == AUTOJANNY_ID)
.order_by(Notification.created_utc.desc()).offset(25 * (page - 1)).limit(101).all())
.order_by(Notification.created_datetimez.desc()).offset(25 * (page - 1)).limit(101).all())
listing = []