Skip to content

Add robot statistics UI - #2826

Open
aeshub wants to merge 6 commits into
equinor:mainfrom
aeshub:robot-page-statistics
Open

Add robot statistics UI#2826
aeshub wants to merge 6 commits into
equinor:mainfrom
aeshub:robot-page-statistics

Conversation

@aeshub

@aeshub aeshub commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add a new GET statistics/robots/{robotId}/missions endpoint (controller + service + DTOs, integration-tested) aggregating mission/task outcomes and weekly mission counts over a time window.
  • Add a robot-scoped Performance section to the robot page: mission success, task completion, and missions-per-week over the last 30 days, drawn with dependency-free inline SVG donut/bar charts.
  • Redesign the robot page around the mission-control NavBar, a breadcrumb, and hero/metrics cards built from EDS Card/Typography.
  • Restyle the documentation list as a compact strip.
  • Add English and Norwegian translations for all new labels.

Notes

  • No new npm dependencies and no DB migration (read-only aggregation).
  • Success semantics: "successful" counts Successful + PartiallySuccessful; mission totals count completed runs only.

@aeshub aeshub added the feature New feature or request label Jul 10, 2026
@aeshub aeshub self-assigned this Jul 10, 2026
@aeshub
aeshub force-pushed the robot-page-statistics branch from a99fa6b to 18e6c4c Compare July 10, 2026 06:38
@aeshub

aeshub commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

Tested locally. Here is what it looks like.
image

aeshub added 6 commits July 10, 2026 10:08
Response models for an upcoming robot-scoped statistics endpoint:
mission run/success counts, task completion, and a per-week mission
trend. SuccessRate is a 0-1 fraction that counts Successful and
PartiallySuccessful runs as successes.
Introduce IStatisticsService/StatisticsService computing per-robot
completed-mission and task success statistics plus weekly mission
counts over a time window, honouring installation access control.
Register it as a scoped service. Consumed by an upcoming statistics
endpoint and the redesigned robot page.
Expose GET statistics/robots/{robotId}/missions returning the
aggregated RobotStatisticsResponse for a creation-time window
(minCreationTime/maxCreationTime as epoch seconds). Both bounds are
required and access is scoped to the caller's readable installations
via StatisticsService.
Cover the robot statistics endpoint against a real Postgres
container: completed-only mission counts and success rate, task
aggregation, creation-time window exclusion, weekly bucketing,
empty results, and request validation.
Mirror the backend RobotStatisticsResponse DTO and add a
getRobotStatistics client method that queries the statistics
endpoint with a Unix-second creation-time window.
Add a "Performance" section to the robot page backed by the new
statistics endpoint: mission success, task completion, and
missions-per-week over the last 30 days, drawn with inline SVG
charts (no new dependencies).

Redesign the page around a NavBar, breadcrumb, hero and metrics
cards, and restyle documentation as a strip. Build everything
from EDS Card and Typography. Add English and Norwegian strings.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds robot performance statistics end-to-end: a new backend aggregation endpoint (with DTOs and integration tests) plus a redesigned Robot page section that renders mission/task success and weekly mission counts using inline SVG charts and new translations.

Changes:

  • Backend: introduce GET statistics/robots/{robotId}/missions with role-filtered aggregation of mission/task outcomes and weekly buckets.
  • Frontend: add a robot-scoped Performance section (donut + bar charts) driven by a new React Query hook and model.
  • UI/UX: restructure Robot page layout around NavBar, breadcrumb/hero cards, and restyle the documentation list; add EN/NO translations.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
frontend/src/pages/RobotPage/RobotStatistics/WeeklyBarChart.tsx New inline-SVG weekly bar chart for missions-per-week.
frontend/src/pages/RobotPage/RobotStatistics/RobotStatisticsSection.tsx New Performance section composing charts and summary stats for a robot.
frontend/src/pages/RobotPage/RobotStatistics/DonutChart.tsx New inline-SVG donut chart used for success/completion rates.
frontend/src/pages/RobotPage/RobotPage.tsx Redesign robot page layout (NavBar, breadcrumb, hero/actions, metrics) and adds statistics section.
frontend/src/pages/RobotPage/Documentation.tsx Restyles documentation list into a compact card/strip layout.
frontend/src/models/RobotStatistics.ts Adds frontend model for robot statistics response payload.
frontend/src/language/no.json Adds Norwegian translations for new performance/statistics/documentation labels.
frontend/src/language/en.json Adds English translations for new performance/statistics/documentation labels.
frontend/src/hooks/useRobotStatistics.tsx New React Query hook to fetch robot statistics over a fixed time window.
frontend/src/api/BackendApi.tsx Adds getRobotStatistics API call to the frontend backend client.
backend/api/Services/StatisticsService.cs Implements aggregation logic for mission/task outcomes and weekly mission counts.
backend/api/Program.cs Registers IStatisticsService in DI container.
backend/api/Controllers/StatisticsController.cs Adds statistics endpoint, validation, and authorization.
backend/api/Controllers/Models/WeeklyMissionCountResponse.cs DTO for weekly mission count bucket.
backend/api/Controllers/Models/TaskStatisticsResponse.cs DTO for aggregated task statistics.
backend/api/Controllers/Models/RobotStatisticsResponse.cs DTO for robot statistics response envelope.
backend/api/Controllers/Models/MissionStatisticsResponse.cs DTO for aggregated mission statistics.
backend/api.test/Controllers/StatisticsControllerTests.cs Integration tests validating endpoint behavior and bucketing semantics.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

ratioCaption={TranslateText('missions successful / run')}
successLegend={TranslateText('successful')}
restCount={missionsUnsuccessful}
restLegend={TranslateText('failed / aborted')}
Comment on lines +164 to +166
<HeadingTitle>{TranslateText('Performance')}</HeadingTitle>
<HeadingSubtitle>{`· ${TranslateText('Last 30 days')}`}</HeadingSubtitle>
</SectionHeading>
const barWidth = Math.min(slotWidth * 0.5, MAX_BAR_WIDTH)

return (
<StyledSvg viewBox={`0 0 ${WIDTH} ${HEIGHT}`} role="img" aria-label="Completed missions per week">
}
if (maxCreationTime < minCreationTime)
{
return BadRequest("Max CreationTime cannot be less than min CreationTime");
.Where(m => CompletedMissionStatuses.Contains(m.Status))
.Where(m =>
accessibleInstallationCodes.Contains(
m.InspectionArea.Installation.InstallationCode.ToUpper()

@andchiind andchiind left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The information to calculate these statistics is already available on the frontend, I don't really see the point of doing these calculations on the backend. I think for a low priority task, it's benefitial to try to keep it as simple as possible. This PR seems to work well, but I am worried that the amount of added complexity will make maintaining it more costly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants