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,
|
||||
|
||||
Reference in New Issue
Block a user