From 3b4211e8e11af5a9933a81ddcbdc90b4b94b2ac6 Mon Sep 17 00:00:00 2001 From: Aevann Date: Sat, 28 Jan 2023 10:25:19 +0200 Subject: [PATCH] stop using nullslast https://fsdfsd.net/rDrama/rDrama/pulls/102 --- files/routes/admin.py | 1 - files/routes/static.py | 2 +- files/routes/subs.py | 8 +++----- files/routes/users.py | 1 - migrations/20230128-stop-using-nullslast.sql | 3 +++ 5 files changed, 7 insertions(+), 8 deletions(-) create mode 100644 migrations/20230128-stop-using-nullslast.sql diff --git a/files/routes/admin.py b/files/routes/admin.py index 56f7265f8..4c514e515 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -2,7 +2,6 @@ import time from urllib.parse import quote, urlencode from math import floor -from sqlalchemy import nullslast from sqlalchemy.exc import IntegrityError from psycopg2.errors import UniqueViolation diff --git a/files/routes/static.py b/files/routes/static.py index 021fbccdb..9a70b17de 100644 --- a/files/routes/static.py +++ b/files/routes/static.py @@ -1,7 +1,7 @@ import os from shutil import copyfile -from sqlalchemy import func, nullslast +from sqlalchemy import func from files.helpers.media import process_files import files.helpers.stats as statshelper diff --git a/files/routes/subs.py b/files/routes/subs.py index 5eec21515..e6b8a4435 100644 --- a/files/routes/subs.py +++ b/files/routes/subs.py @@ -1,5 +1,3 @@ -from sqlalchemy import nullslast - from files.classes import * from files.helpers.alerts import * from files.helpers.get import * @@ -201,7 +199,7 @@ def sub_exilees(v:User, sub): abort(403) users = g.db.query(User, Exile).join(Exile, Exile.user_id==User.id) \ .filter_by(sub=sub.name) \ - .order_by(nullslast(Exile.created_utc.desc()), User.username).all() + .order_by(Exile.created_utc.desc(), User.username).all() return render_template("sub/exilees.html", v=v, sub=sub, users=users) @@ -215,7 +213,7 @@ def sub_blockers(v:User, sub): abort(403) users = g.db.query(User, SubBlock).join(SubBlock) \ .filter_by(sub=sub.name) \ - .order_by(nullslast(SubBlock.created_utc.desc()), User.username).all() + .order_by(SubBlock.created_utc.desc(), User.username).all() return render_template("sub/blockers.html", v=v, sub=sub, users=users, verb="blocking") @@ -230,7 +228,7 @@ def sub_followers(v:User, sub): abort(403) users = g.db.query(User, SubSubscription).join(SubSubscription) \ .filter_by(sub=sub.name) \ - .order_by(nullslast(SubSubscription.created_utc.desc()), User.username).all() + .order_by(SubSubscription.created_utc.desc(), User.username).all() return render_template("sub/blockers.html", v=v, sub=sub, users=users, verb="following") diff --git a/files/routes/users.py b/files/routes/users.py index 3bf57c05c..3314ffbd8 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -7,7 +7,6 @@ from typing import Literal import gevent import qrcode -from sqlalchemy import nullslast from sqlalchemy.orm import aliased from files.classes import * diff --git a/migrations/20230128-stop-using-nullslast.sql b/migrations/20230128-stop-using-nullslast.sql new file mode 100644 index 000000000..6a4215155 --- /dev/null +++ b/migrations/20230128-stop-using-nullslast.sql @@ -0,0 +1,3 @@ +update sub_blocks set created_utc=0 where created_utc is null; +update exiles set created_utc=0 where created_utc is null; +update sub_subscriptions set created_utc=0 where created_utc is null;