feat: sort library files by date
This commit is contained in:
parent
e256d50c5c
commit
f65ef64a77
@ -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
|
||||
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user