diff --git a/database.py b/database.py index f5b6e20..b589248 100644 --- a/database.py +++ b/database.py @@ -24,6 +24,8 @@ class Condition: sql = "TRUE" if self._order_by: sql += f" ORDER BY {self._order_by}" + if self._desc: + sql += " DESC" if self._limit: sql += f" LIMIT {self._limit}" if self._offset: @@ -31,7 +33,6 @@ class Condition: if self.has_regex and conn: conn.create_function("REGEXP", 2, self._regexp) - print(sql) return sql @staticmethod @@ -179,8 +180,9 @@ class Condition: return self - def order_by(self, order_by): + def order_by(self, order_by, desc=False): self._order_by = order_by + self._desc = desc return self diff --git a/interface.py b/interface.py index c2afa26..d9b079f 100644 --- a/interface.py +++ b/interface.py @@ -389,6 +389,8 @@ def build_library_query_condition(form): for keyword in keywords: condition.and_like("title", f"%{keyword}%", case_sensitive=False) + condition.order_by('create_at', desc=True) + return condition except KeyError: abort(400)