04/27 Fixed some issues 3
This commit is contained in:
+31
-6
@@ -47,6 +47,25 @@ def _notify_followers(issue, title, body, exclude_user_ids=None):
|
||||
|
||||
# ── List ──────────────────────────────────────────────────────────────────────
|
||||
|
||||
class _SLAFilteredPage:
|
||||
"""Minimal pagination-compatible wrapper used when an SLA filter is active.
|
||||
|
||||
The SLA status is a computed value (not a DB column), so it cannot be
|
||||
filtered at the query level. When sla_filter is set we load all matching
|
||||
rows, apply the Python-side filter, and wrap the result in this object so
|
||||
the template can use the same interface (.items, .pages, .page, .iter_pages)
|
||||
without any template changes. Pagination is suppressed (single page) since
|
||||
the full filtered set is always returned.
|
||||
"""
|
||||
def __init__(self, items):
|
||||
self.items = items
|
||||
self.page = 1
|
||||
self.pages = 1
|
||||
|
||||
def iter_pages(self, **kwargs):
|
||||
return iter([1])
|
||||
|
||||
|
||||
@bp.route('/')
|
||||
@login_required
|
||||
def index():
|
||||
@@ -79,13 +98,20 @@ def index():
|
||||
Area.facility_id == int(facility_filter)
|
||||
)
|
||||
|
||||
# SLA filter — applied in Python after DB query since SLA is computed
|
||||
issues_paged = q.paginate(page=page, per_page=25, error_out=False)
|
||||
|
||||
# SLA filter — SLA status is computed in Python (not a DB column).
|
||||
# When active: load all matching rows, filter in Python, wrap in a
|
||||
# single-page compatible object so the template interface is unchanged.
|
||||
# When inactive: use standard DB-level pagination (25 per page).
|
||||
if sla_filter:
|
||||
filtered_items = [i for i in issues_paged.items if sla_status(i) == sla_filter]
|
||||
all_issues = q.all()
|
||||
filtered = [i for i in all_issues if sla_status(i) == sla_filter]
|
||||
issues_paged = _SLAFilteredPage(filtered)
|
||||
logger.debug(
|
||||
'ISSUES | index | sla_filter=%s | matched=%s of %s',
|
||||
sla_filter, len(filtered), len(all_issues),
|
||||
)
|
||||
else:
|
||||
filtered_items = issues_paged.items
|
||||
issues_paged = q.paginate(page=page, per_page=25, error_out=False)
|
||||
|
||||
# Build a set of issue IDs the current user is following so the template
|
||||
# can render the following badge and inline unfollow button without an
|
||||
@@ -111,7 +137,6 @@ def index():
|
||||
|
||||
return render_template('issues/list.html',
|
||||
issues=issues_paged,
|
||||
issue_items=filtered_items,
|
||||
severity_filter=severity_filter,
|
||||
status_filter=status_filter,
|
||||
sla_filter=sla_filter,
|
||||
|
||||
Reference in New Issue
Block a user