use PAGE_LIMIT in alias_log
This commit is contained in:
parent
40cac56986
commit
1e4bab765d
|
@ -2,12 +2,11 @@ import arrow
|
||||||
from flask import render_template, flash, redirect, url_for
|
from flask import render_template, flash, redirect, url_for
|
||||||
from flask_login import login_required, current_user
|
from flask_login import login_required, current_user
|
||||||
|
|
||||||
|
from app.config import PAGE_LIMIT
|
||||||
from app.dashboard.base import dashboard_bp
|
from app.dashboard.base import dashboard_bp
|
||||||
from app.extensions import db
|
from app.extensions import db
|
||||||
from app.models import GenEmail, ForwardEmailLog, ForwardEmail
|
from app.models import GenEmail, ForwardEmailLog, ForwardEmail
|
||||||
|
|
||||||
_LIMIT = 15
|
|
||||||
|
|
||||||
|
|
||||||
class AliasLog:
|
class AliasLog:
|
||||||
website_email: str
|
website_email: str
|
||||||
|
@ -54,7 +53,7 @@ def alias_log(alias_id, page_id):
|
||||||
email_replied = base.filter(ForwardEmailLog.is_reply == True).count()
|
email_replied = base.filter(ForwardEmailLog.is_reply == True).count()
|
||||||
email_blocked = base.filter(ForwardEmailLog.blocked == True).count()
|
email_blocked = base.filter(ForwardEmailLog.blocked == True).count()
|
||||||
last_page = (
|
last_page = (
|
||||||
len(logs) < _LIMIT
|
len(logs) < PAGE_LIMIT
|
||||||
) # lightweight pagination without counting all objects
|
) # lightweight pagination without counting all objects
|
||||||
|
|
||||||
return render_template("dashboard/alias_log.html", **locals())
|
return render_template("dashboard/alias_log.html", **locals())
|
||||||
|
@ -68,8 +67,8 @@ def get_alias_log(gen_email: GenEmail, page_id=0):
|
||||||
.filter(ForwardEmail.id == ForwardEmailLog.forward_id)
|
.filter(ForwardEmail.id == ForwardEmailLog.forward_id)
|
||||||
.filter(ForwardEmail.gen_email_id == gen_email.id)
|
.filter(ForwardEmail.gen_email_id == gen_email.id)
|
||||||
.order_by(ForwardEmailLog.id.desc())
|
.order_by(ForwardEmailLog.id.desc())
|
||||||
.limit(_LIMIT)
|
.limit(PAGE_LIMIT)
|
||||||
.offset(page_id * _LIMIT)
|
.offset(page_id * PAGE_LIMIT)
|
||||||
)
|
)
|
||||||
|
|
||||||
for fe, fel in q:
|
for fe, fel in q:
|
||||||
|
|
Loading…
Reference in a new issue