feat: sort library files by date
This commit is contained in:
parent
e256d50c5c
commit
f65ef64a77
@ -24,6 +24,8 @@ class Condition:
|
|||||||
sql = "TRUE"
|
sql = "TRUE"
|
||||||
if self._order_by:
|
if self._order_by:
|
||||||
sql += f" ORDER BY {self._order_by}"
|
sql += f" ORDER BY {self._order_by}"
|
||||||
|
if self._desc:
|
||||||
|
sql += " DESC"
|
||||||
if self._limit:
|
if self._limit:
|
||||||
sql += f" LIMIT {self._limit}"
|
sql += f" LIMIT {self._limit}"
|
||||||
if self._offset:
|
if self._offset:
|
||||||
@ -31,7 +33,6 @@ class Condition:
|
|||||||
if self.has_regex and conn:
|
if self.has_regex and conn:
|
||||||
conn.create_function("REGEXP", 2, self._regexp)
|
conn.create_function("REGEXP", 2, self._regexp)
|
||||||
|
|
||||||
print(sql)
|
|
||||||
return sql
|
return sql
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -179,8 +180,9 @@ class Condition:
|
|||||||
|
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def order_by(self, order_by):
|
def order_by(self, order_by, desc=False):
|
||||||
self._order_by = order_by
|
self._order_by = order_by
|
||||||
|
self._desc = desc
|
||||||
|
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
@ -389,6 +389,8 @@ def build_library_query_condition(form):
|
|||||||
for keyword in keywords:
|
for keyword in keywords:
|
||||||
condition.and_like("title", f"%{keyword}%", case_sensitive=False)
|
condition.and_like("title", f"%{keyword}%", case_sensitive=False)
|
||||||
|
|
||||||
|
condition.order_by('create_at', desc=True)
|
||||||
|
|
||||||
return condition
|
return condition
|
||||||
except KeyError:
|
except KeyError:
|
||||||
abort(400)
|
abort(400)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user