Jul 9 - Update Dashboard separate open issue by Handler (more viewable)
This commit is contained in:
+19
-7
@@ -17,6 +17,16 @@ bp = Blueprint('dashboard', __name__)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def _handler_split(issues):
|
||||
"""Count a list of Issues by handler_type (phase35). Rows default to
|
||||
'internal' when unset. Returns a dict keyed internal/facility/vendor."""
|
||||
return {
|
||||
'internal': sum(1 for i in issues if (i.handler_type or 'internal') == 'internal'),
|
||||
'facility': sum(1 for i in issues if i.handler_type == 'facility'),
|
||||
'vendor': sum(1 for i in issues if i.handler_type == 'vendor'),
|
||||
}
|
||||
|
||||
|
||||
@bp.route('/')
|
||||
@bp.route('/dashboard')
|
||||
@login_required
|
||||
@@ -96,11 +106,7 @@ def index():
|
||||
'low': sum(1 for i in open_issues_all if i.severity == 'low'),
|
||||
}
|
||||
# Open issues split by who handles them (phase35) — same list, no extra query.
|
||||
handler_breakdown = {
|
||||
'internal': sum(1 for i in open_issues_all if (i.handler_type or 'internal') == 'internal'),
|
||||
'facility': sum(1 for i in open_issues_all if i.handler_type == 'facility'),
|
||||
'vendor': sum(1 for i in open_issues_all if i.handler_type == 'vendor'),
|
||||
}
|
||||
handler_breakdown = _handler_split(open_issues_all)
|
||||
|
||||
# ── Issues resolved today ─────────────────────────────────────────────────
|
||||
resolved_today_q = Issue.query.filter(
|
||||
@@ -235,7 +241,9 @@ def index():
|
||||
Issue.facility_id.in_(customer_facility_ids),
|
||||
_AreaT.facility_id.in_(customer_facility_ids),
|
||||
))
|
||||
issues_opened_today = opened_today_q.count()
|
||||
opened_today_all = opened_today_q.all()
|
||||
issues_opened_today = len(opened_today_all)
|
||||
opened_today_handler = _handler_split(opened_today_all)
|
||||
|
||||
# ── Pending verification ──────────────────────────────────────────────────
|
||||
from app.models.facility import Area as _AreaV
|
||||
@@ -297,7 +305,9 @@ def index():
|
||||
))
|
||||
elif is_customer:
|
||||
unassigned_q = unassigned_q.filter(False) # not relevant for customers
|
||||
unassigned_open = unassigned_q.count()
|
||||
unassigned_all = unassigned_q.all()
|
||||
unassigned_open = len(unassigned_all)
|
||||
unassigned_handler = _handler_split(unassigned_all)
|
||||
|
||||
# ── Inspector activity today (admin / director / PM only) ─────────────────
|
||||
inspector_activity = []
|
||||
@@ -372,9 +382,11 @@ def index():
|
||||
resolved_today = resolved_today,
|
||||
pending_followups = pending_followups,
|
||||
issues_opened_today = issues_opened_today,
|
||||
opened_today_handler = opened_today_handler,
|
||||
pending_verification = pending_verification,
|
||||
stale_in_progress = stale_in_progress,
|
||||
unassigned_open = unassigned_open,
|
||||
unassigned_handler = unassigned_handler,
|
||||
inspector_activity = inspector_activity,
|
||||
recent_inspections = recent_inspections,
|
||||
total_facilities = total_facilities,
|
||||
|
||||
@@ -113,11 +113,14 @@ def export_list_pdf():
|
||||
date_to_filter = request.args.get('date_to', '')
|
||||
reporter_filter = request.args.get('reporter_id', '')
|
||||
handler_filter = request.args.get('handler_type', '')
|
||||
unassigned_filter = request.args.get('unassigned', '')
|
||||
|
||||
if issue_id_filter.isdigit():
|
||||
q = q.filter(Issue.id == int(issue_id_filter))
|
||||
if handler_filter in ('internal', 'facility', 'vendor'):
|
||||
q = q.filter(Issue.handler_type == handler_filter)
|
||||
if unassigned_filter:
|
||||
q = q.filter(Issue.assigned_to.is_(None))
|
||||
if severity_filter:
|
||||
q = q.filter(Issue.severity == severity_filter)
|
||||
if status_filter:
|
||||
@@ -247,11 +250,14 @@ def index():
|
||||
date_to_filter = request.args.get('date_to', '')
|
||||
reporter_filter = request.args.get('reporter_id', '')
|
||||
handler_filter = request.args.get('handler_type', '')
|
||||
unassigned_filter = request.args.get('unassigned', '')
|
||||
|
||||
if issue_id_filter.isdigit():
|
||||
q = q.filter(Issue.id == int(issue_id_filter))
|
||||
if handler_filter in ('internal', 'facility', 'vendor'):
|
||||
q = q.filter(Issue.handler_type == handler_filter)
|
||||
if unassigned_filter:
|
||||
q = q.filter(Issue.assigned_to.is_(None))
|
||||
if severity_filter:
|
||||
q = q.filter(Issue.severity == severity_filter)
|
||||
if status_filter:
|
||||
@@ -359,6 +365,7 @@ def index():
|
||||
date_to_filter=date_to_filter,
|
||||
reporter_filter=reporter_filter,
|
||||
handler_filter=handler_filter,
|
||||
unassigned_filter=unassigned_filter,
|
||||
facilities=facilities,
|
||||
projects=projects,
|
||||
staff=staff,
|
||||
|
||||
Reference in New Issue
Block a user