Skip to content

[O2B-1623] Document the LHC periods statistics endpoints in the HTTP API documentation - #2271

Open
graduta wants to merge 6 commits into
mainfrom
feature/O2B-1623/docs-lhc-periods-statistics-endpoints
Open

graduta wants to merge 6 commits into
mainfrom
feature/O2B-1623/docs-lhc-periods-statistics-endpoints

Conversation

@graduta

@graduta graduta commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

I have a JIRA ticket

  • branch and/or PR name(s) include(s) JIRA ID
  • issue has "Fix version" assigned
  • issue "Status" is set to "In review"
  • PR labels are selected

Part of a stack of PRs documenting the HTTP API (O2B-1623). The earlier PRs of the stack are merged: this one is rebased on main and regenerated with the current generator. It is the last PR of the stack.

Notable changes for users:

  • GET /api/lhcPeriodsStatistics/{lhcPeriodId} now rejects (400) an id that is not a positive integer (0, negative numbers, decimals), instead of answering with a 404.
  • The LHC periods statistics endpoints are now documented at /api-docs, with parameters, responses and curl examples:
    • GET /api/lhcPeriodsStatistics: paginated list with filters (ids, names, years, PDP beam types) and sorting
    • GET /api/lhcPeriodsStatistics/{lhcPeriodId}: statistics of one LHC period

Notable changes for developers:

  • Checked the chain of the endpoint: all files have their license header, no use case is involved, the entity has no createdAt / updatedAt, and the router references existing handlers.
  • LhcPeriodStatisticsService queried the repository directly (with an inline sub-query for the PDP beam types) and has no small functions: it now uses getLhcPeriodStatistics, getLhcPeriodStatisticsOrFail, getAllLhcPeriodStatistics(qbConfiguration) and getLhcPeriodStatisticsIdsByPdpBeamTypes (each id returned once), and prepareQueryBuilder can reuse an existing query builder. The behaviour is unchanged (same not found message, same BadParameterError) and the four functions have tests. A & used instead of && in the check of the id is fixed.
  • Removed lib/server/services/period/getOrCreateLhcPeriod.js: an unused copy of lib/server/services/lhcPeriod/getOrCreateLhcPeriod.js (nothing required it).
  • The controller disabled the JSDoc rules for the whole file, its handlers are documented; the documentation of the service, of getOrCreateLhcPeriod and of getLhcPeriod, copied from the run types and the logs, describes LHC periods.
  • The id of the endpoint is validated with EntityIdDto (it was a plain Joi.number()), with an API test of the four kinds of invalid values.
  • lib/server/api-docs/openapi.yaml is updated by hand, API.md and index.html are regenerated with npm run docs:api (separate commit).
  • Statistics are computed on the physics runs of each period.

Changes made to the database:

  • None

🤖 Generated with Claude Code

@graduta
graduta requested a review from isaachilly as a code owner October 20, 2026 13:04
@graduta
graduta added this pull request to stack #2265 October 20, 2026 13:04
@graduta graduta changed the title feature/O2B 1623/docs lhc periods statistics endpoints [O2B-1623] Document the LHC periods statistics endpoints in the HTTP API documentation Oct 20, 2026
@graduta graduta added documentation Improvements or additions to documentation backend labels Oct 20, 2026
@codecov

codecov Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 46.54%. Comparing base (2249a99) to head (ec34926).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2271      +/-   ##
==========================================
+ Coverage   46.45%   46.54%   +0.08%     
==========================================
  Files        1054     1057       +3     
  Lines       17379    17404      +25     
  Branches     3165     3174       +9     
==========================================
+ Hits         8073     8100      +27     
+ Misses       9306     9304       -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@graduta
graduta removed this pull request from stack #2265 October 22, 2026 09:29
@graduta
graduta added this pull request to stack #2276 October 22, 2026 09:30
Base automatically changed from feature/O2B-1623/docs-simulation-passes-endpoints to main October 22, 2026 12:53
`lib/server/services/period/getOrCreateLhcPeriod.js` was a copy of `lib/server/services/lhcPeriod/getOrCreateLhcPeriod.js`, which is the one used by `RunService`, by the MonAlisa
synchronizer and by the tests. Nothing required the copy: the only thing it had more was a `LhcPeriodIdentifier` typedef that `LhcPeriodStatisticsService` already defines.
The controller disabled the JSDoc rules for the whole file: its two handlers now describe their parameters and their result. The documentation of
`getOrCreateLhcPeriod` described a run type, it describes the LHC period.
`LhcPeriodStatisticsService` queried the repository directly, including an inline sub-query to filter on PDP beam types. It now relies on small functions:
`getLhcPeriodStatistics` and `getLhcPeriodStatisticsOrFail` (find by id or name), `getAllLhcPeriodStatistics(qbConfiguration)` and
`getLhcPeriodStatisticsIdsByPdpBeamTypes` (each id returned once), and `prepareQueryBuilder` can reuse an existing query builder. The behaviour is unchanged
(the not found message and the `BadParameterError` stay the same), and the four functions have their own tests.

This also fixes a `&` used instead of `&&` in the check of the id, and the documentation of the service that described a run type.
…r entity ids

`GET /api/lhcPeriodsStatistics/:lhcPeriodId` accepted any number (`0`, negative numbers, decimals) and answered with a 404. The id is now validated with `EntityIdDto`,
so that invalid values are rejected with a 400, and an API test checks the four kinds of invalid ids.
@graduta
graduta force-pushed the feature/O2B-1623/docs-lhc-periods-statistics-endpoints branch from c43d848 to ec34926 Compare October 22, 2026 12:58

This branch has not been deployed

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

Labels

backend documentation Improvements or additions to documentation

Development

Successfully merging this pull request may close these issues.

2 participants