mirror of
https://github.com/simple-login/app.git
synced 2024-11-11 10:06:11 +08:00
order alias by most recent ones
This commit is contained in:
parent
d6020d5fa0
commit
8c14c25cec
1 changed files with 9 additions and 5 deletions
|
@ -148,10 +148,14 @@ def get_alias_info(user_id, query=None, highlight_gen_email_id=None) -> [AliasIn
|
||||||
query = query.strip().lower()
|
query = query.strip().lower()
|
||||||
|
|
||||||
aliases = {} # dict of alias and AliasInfo
|
aliases = {} # dict of alias and AliasInfo
|
||||||
q = db.session.query(GenEmail, ForwardEmail, ForwardEmailLog).filter(
|
q = (
|
||||||
GenEmail.user_id == user_id,
|
db.session.query(GenEmail, ForwardEmail, ForwardEmailLog)
|
||||||
GenEmail.id == ForwardEmail.gen_email_id,
|
.filter(
|
||||||
ForwardEmail.id == ForwardEmailLog.forward_id,
|
GenEmail.user_id == user_id,
|
||||||
|
GenEmail.id == ForwardEmail.gen_email_id,
|
||||||
|
ForwardEmail.id == ForwardEmailLog.forward_id,
|
||||||
|
)
|
||||||
|
.order_by(GenEmail.created_at.desc())
|
||||||
)
|
)
|
||||||
|
|
||||||
if query:
|
if query:
|
||||||
|
@ -180,7 +184,7 @@ def get_alias_info(user_id, query=None, highlight_gen_email_id=None) -> [AliasIn
|
||||||
db.session.query(GenEmail)
|
db.session.query(GenEmail)
|
||||||
.filter(GenEmail.email.notin_(aliases.keys()))
|
.filter(GenEmail.email.notin_(aliases.keys()))
|
||||||
.filter(GenEmail.user_id == user_id)
|
.filter(GenEmail.user_id == user_id)
|
||||||
)
|
).order_by(GenEmail.created_at.desc())
|
||||||
|
|
||||||
if query:
|
if query:
|
||||||
q = q.filter(GenEmail.email.contains(query))
|
q = q.filter(GenEmail.email.contains(query))
|
||||||
|
|
Loading…
Reference in a new issue