Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions backend/apps/owasp/api/internal/nodes/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,15 @@ def contribution_stats(self, root: Project) -> strawberry.scalars.JSON | None:
def health_metrics_list(
self, root: Project, limit: int = 30
) -> list[ProjectHealthMetricsNode]:
"""Resolve project health metrics."""
"""Resolve project health metrics for chart display.

Returns the N most recent metrics in chronological order (oldest to newest)
so charts display correctly from left to right.
"""
if (normalized_limit := normalize_limit(limit, MAX_LIMIT)) is None:
return []

return root.health_metrics.order_by("nest_created_at")[:normalized_limit]
return list(reversed(root.health_metrics.order_by("-nest_created_at")[:normalized_limit]))

@strawberry_django.field(prefetch_related=["health_metrics"])
def health_metrics_latest(self, root: Project) -> ProjectHealthMetricsNode | None:
Expand Down