Skip to content

[O2B-1623] Document the ctp-trigger-counters endpoint in the HTTP API documentation - #2268

Merged
graduta merged 7 commits into
mainfrom
feature/O2B-1623/docs-ctp-trigger-counters-endpoint
Oct 22, 2026
Merged

graduta merged 7 commits into
mainfrom
feature/O2B-1623/docs-ctp-trigger-counters-endpoint

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. The following PRs of the stack are rebased one by one, once the previous one is merged.

Notable changes for users:

  • GET /api/ctp-trigger-counters/{runNumber} now answers 404 for a run that does not exist, instead of 200 with an empty list (like /api/runs/{runNumber}/logs and /flps). A run that exists but has no counters still gives an empty list.
  • GET /api/ctp-trigger-counters/{runNumber} now rejects (400) a run number that is not a positive integer (0, negative numbers, decimals), instead of answering with an empty list.
  • createdAt and updatedAt are no longer sent for CTP trigger counters (breaking for any external client reading them).
  • The ctp-trigger-counters endpoints are now documented at /api-docs, with parameters, responses and curl examples:
    • GET /api/ctp-trigger-counters/{runNumber}: trigger counters of a run, per trigger class (a run without counters gives an empty list, a run that does not exist gives a 404)

Notable changes for developers:

  • CtpTriggerCountersService.getPerRun fetches the counters first and only checks the run (getRunOrFail) when none is found, so the common case is a single query. This is sound because counters can only exist for an existing run: ctp_trigger_counters.run_number is a foreign key to runs and the only writer (createOrUpdatePerRun) checks the run.
  • The run number of the endpoint is validated with EntityIdDto, like in GetRunDto, instead of a plain Joi.number(). An API test checks the four kinds of invalid values.
  • CtpTriggerCountersService is built on two small functions, getAllCtpTriggerCounters(qbConfiguration) (returns models) and createOrUpdateCtpTriggerCounters(criteria, counters), instead of using the repository directly, like run types, detectors and tags. The public API of the service (getPerRun, createOrUpdatePerRun), the adapter and the run existence check are unchanged. Both functions have tests.
  • The router, the controller, the service, the model, the migration renaming the table and three tests of the CTP trigger counters had no license header (nearly all the other files of their layers have one): added. The HTTP and gRPC handlers are documented instead of disabling the JSDoc rules, and the className parameter of the service was documented as a run number.
  • CtpTriggerCountersAdapter.toEntity (only used by CtpTriggerCountersService.getPerRun) no longer returns createdAt and updatedAt: nothing uses them (the run details page only reads the class name and the counters, and the service test already removed the dates before comparing). The CtpTriggerCounters typedef is updated and the API test checks the returned keys.
  • lib/server/api-docs/openapi.yaml is updated by hand, API.md and index.html are regenerated with npm run docs:api (separate commit).

Changes made to the database:

  • None

🤖 Generated with Claude Code

@graduta
graduta requested a review from isaachilly as a code owner October 20, 2026 12:59
@graduta
graduta added this pull request to stack #2265 October 20, 2026 12:59
@graduta graduta changed the title feature/O2B 1623/docs ctp trigger counters endpoint [O2B-1623] Document the ctp-trigger-counters endpoint 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.40%. Comparing base (19720a1) to head (260724d).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2268      +/-   ##
==========================================
+ Coverage   46.36%   46.40%   +0.04%     
==========================================
  Files        1049     1051       +2     
  Lines       17351    17363      +12     
  Branches     3160     3161       +1     
==========================================
+ Hits         8044     8057      +13     
+ Misses       9307     9306       -1     

☔ 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-run-types-endpoints to main October 22, 2026 10:08
@graduta
graduta force-pushed the feature/O2B-1623/docs-ctp-trigger-counters-endpoint branch 2 times, most recently from 0b6a793 to 4c7e365 Compare October 22, 2026 10:52
…TP trigger counters files

The router, the controller, the service, the model, the migration renaming the table and the three tests of the CTP trigger counters had no license header, unlike
nearly all the other files of their layers. The HTTP and gRPC controllers handlers are now documented instead of disabling the JSDoc rules, and the service
documentation of `className` is fixed (it described the run number).
`CtpTriggerCountersService` used the repository directly. It now relies on two small functions, `getAllCtpTriggerCounters(qbConfiguration)` returning models and
`createOrUpdateCtpTriggerCounters(criteria, counters)`, and keeps the adapter, the run existence check and the public API (`getPerRun`, `createOrUpdatePerRun`), as
it is done for run types, detectors and tags. Both small functions have their own tests.
…he other run endpoints

`GET /api/ctp-trigger-counters/:runNumber` accepted any number (`0`, negative numbers, decimals) and answered with an empty list. The run number is now validated with
`EntityIdDto` like in `GetRunDto`, so that invalid values are rejected with a 400. An API test checks the four kinds of invalid run numbers.
@graduta
graduta force-pushed the feature/O2B-1623/docs-ctp-trigger-counters-endpoint branch from 4c7e365 to 1e10853 Compare October 22, 2026 11:40
… not exist

`GET /api/ctp-trigger-counters/:runNumber` answered `200` with an empty list for a run that does not exist, unlike the other endpoints reading data of a run
(`/api/runs/:runNumber/logs`, `/api/runs/:runNumber/flps`), which hides a wrong run number. The counters are fetched first and the run is only checked when
none is found, to tell a run without counters (empty list) from a missing run (`NotFoundError`, so a 404): counters can only exist for an existing run, as
`ctp_trigger_counters.run_number` is a foreign key, so the common case still costs a single query.
Nothing uses the creation and update dates of the CTP trigger counters: the run details page only reads the class name and the counters (`lmb`, `lma`, `l0b`,
`l0a`, `l1b`, `l1a`), the service test already removes the dates before comparing, and `CtpTriggerCountersAdapter.toEntity` is only used by
`CtpTriggerCountersService.getPerRun`. The adapter now stops returning them, the `CtpTriggerCounters` typedef is updated and the API test checks the returned keys.
@graduta
graduta force-pushed the feature/O2B-1623/docs-ctp-trigger-counters-endpoint branch from 1e10853 to 260724d Compare October 22, 2026 11:51
@graduta
graduta merged commit 56aac9e into main Oct 22, 2026
26 checks passed
@graduta
graduta deleted the feature/O2B-1623/docs-ctp-trigger-counters-endpoint branch October 22, 2026 11:57
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