Skip to content

Commit 63833ec

Browse files
gradutaclaude
andauthored
[O2B-1623] Document the shift-data endpoint in the HTTP API documentation (#2269)
* [O2B-1623] Document the shift data handler * [O2B-1623] Document the shift-data endpoint in the HTTP API specification * [O2B-1623] Regenerate the HTTP API documentation with the shift-data endpoint --------- Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
1 parent 56aac9e commit 63833ec

4 files changed

Lines changed: 147 additions & 2 deletions

File tree

‎lib/server/api-docs/API.md‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,3 +350,32 @@ Responses:
350350
```bash
351351
curl -g "$BOOKKEEPING_URL/api/ctp-trigger-counters/106?token=$TOKEN"
352352
```
353+
354+
## Shifts
355+
356+
Data used to fill end-of-shift reports.
357+
358+
### `GET /shift-data` - Get the data of the pending shift of the calling user
359+
360+
Operation id: `getShiftData`
361+
362+
Returns what a shifter needs to write their end-of-shift (EoS) report for the **pending shift**: the current shift, or the previous one
363+
during the 30 minutes that follow its end. Shifts last 8 hours and are Night (23h-7h), Morning (7h-15h) and Afternoon (15h-23h) in the
364+
Geneva time zone. The shift is deduced from the current time and the calling user, not from a parameter.
365+
366+
`typeSpecific` depends on `shiftType`: `{ environments }` for `ECS`, `{ runs }` for `QC/PDP`, `{ runs, tagsCounters }` for `SL`, and `null`
367+
for `SLIMOS` and `DCS`.
368+
369+
| Parameter | In | Type | Required | Notes |
370+
| --- | --- | --- | --- | --- |
371+
| `shiftType` | query | string | yes | Kind of shift. |
372+
373+
Responses:
374+
375+
- `200`: The shift data.
376+
- `400`: The request failed validation. HTTP status is 400 although each error's `status` field is `"422"`. `source.pointer` has the form `/data/attributes/<query|params|body>/<field>`.
377+
- `404`: The calling user is not known to Bookkeeping.
378+
379+
```bash
380+
curl -g "$BOOKKEEPING_URL/api/shift-data?shiftType=ECS&token=$TOKEN"
381+
```

‎lib/server/api-docs/index.html‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,44 @@ <h2>CTP trigger counters</h2>
570570
<pre><code class="language-bash">curl -g &quot;$BOOKKEEPING_URL/api/ctp-trigger-counters/106?token=$TOKEN&quot;
571571
</code></pre>
572572
</details>
573+
<h2>Shifts</h2>
574+
<p>Data used to fill end-of-shift reports.</p>
575+
<details>
576+
<summary><h3><span class="method get">GET</span> <code>/shift-data</code> - Get the data of the pending shift of the calling user</h3></summary>
577+
578+
<p>Operation id: <code>getShiftData</code></p>
579+
<p>Returns what a shifter needs to write their end-of-shift (EoS) report for the <strong>pending shift</strong>: the current shift, or the previous one
580+
during the 30 minutes that follow its end. Shifts last 8 hours and are Night (23h-7h), Morning (7h-15h) and Afternoon (15h-23h) in the
581+
Geneva time zone. The shift is deduced from the current time and the calling user, not from a parameter.</p>
582+
<p><code>typeSpecific</code> depends on <code>shiftType</code>: <code>{ environments }</code> for <code>ECS</code>, <code>{ runs }</code> for <code>QC/PDP</code>, <code>{ runs, tagsCounters }</code> for <code>SL</code>, and <code>null</code>
583+
for <code>SLIMOS</code> and <code>DCS</code>.</p>
584+
<table>
585+
<thead>
586+
<tr>
587+
<th>Parameter</th>
588+
<th>In</th>
589+
<th>Type</th>
590+
<th>Required</th>
591+
<th>Notes</th>
592+
</tr>
593+
</thead>
594+
<tbody><tr>
595+
<td><code>shiftType</code></td>
596+
<td>query</td>
597+
<td>string</td>
598+
<td>yes</td>
599+
<td>Kind of shift.</td>
600+
</tr>
601+
</tbody></table>
602+
<p>Responses:</p>
603+
<ul>
604+
<li><code>200</code>: The shift data.</li>
605+
<li><code>400</code>: The request failed validation. HTTP status is 400 although each error&#39;s <code>status</code> field is <code>&quot;422&quot;</code>. <code>source.pointer</code> has the form <code>/data/attributes/&lt;query|params|body&gt;/&lt;field&gt;</code>.</li>
606+
<li><code>404</code>: The calling user is not known to Bookkeeping.</li>
607+
</ul>
608+
<pre><code class="language-bash">curl -g &quot;$BOOKKEEPING_URL/api/shift-data?shiftType=ECS&amp;token=$TOKEN&quot;
609+
</code></pre>
610+
</details>
573611

574612
</main>
575613
<footer>Generated from openapi.yaml by <code>npm run docs:api</code> · ALICE Bookkeeping · internal use only</footer>

‎lib/server/api-docs/openapi.yaml‎

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ tags:
4747
description: Types of runs (e.g. calibration kinds).
4848
- name: CTP trigger counters
4949
description: Counters of the central trigger processor, per run and trigger class.
50+
- name: Shifts
51+
description: Data used to fill end-of-shift reports.
5052

5153
paths:
5254
/tags:
@@ -394,6 +396,37 @@ paths:
394396
errors:
395397
- { status: 404, title: Not found, detail: Run with this run number (999999999) could not be found }
396398

399+
/shift-data:
400+
get:
401+
tags: [Shifts]
402+
operationId: getShiftData
403+
summary: Get the data of the pending shift of the calling user
404+
description: |
405+
Returns what a shifter needs to write their end-of-shift (EoS) report for the **pending shift**: the current shift, or the previous one
406+
during the 30 minutes that follow its end. Shifts last 8 hours and are Night (23h-7h), Morning (7h-15h) and Afternoon (15h-23h) in the
407+
Geneva time zone. The shift is deduced from the current time and the calling user, not from a parameter.
408+
409+
`typeSpecific` depends on `shiftType`: `{ environments }` for `ECS`, `{ runs }` for `QC/PDP`, `{ runs, tagsCounters }` for `SL`, and `null`
410+
for `SLIMOS` and `DCS`.
411+
parameters:
412+
- name: shiftType
413+
in: query
414+
required: true
415+
description: Kind of shift.
416+
schema: { type: string, enum: [ECS, QC/PDP, SLIMOS, SL, DCS], examples: [ECS] }
417+
responses:
418+
'200':
419+
description: The shift data.
420+
content:
421+
application/json:
422+
schema: { $ref: '#/components/schemas/ShiftDataResponse' }
423+
'400': { $ref: '#/components/responses/ValidationError' }
424+
'404':
425+
description: The calling user is not known to Bookkeeping.
426+
content:
427+
application/json:
428+
schema: { $ref: '#/components/schemas/ErrorResponse' }
429+
397430
components:
398431
securitySchemes:
399432
jwtQuery:
@@ -596,3 +629,43 @@ components:
596629
data:
597630
type: array
598631
items: { $ref: '#/components/schemas/CtpTriggerCounters' }
632+
Shift:
633+
type: object
634+
required: [start, end, period]
635+
properties:
636+
start: { type: integer, description: Epoch milliseconds. }
637+
end: { type: integer, description: Epoch milliseconds. }
638+
period: { type: string, enum: [Night, Morning, Afternoon] }
639+
ShiftData:
640+
type: object
641+
required: [shift, issuesLogs, typeSpecific, infoFromPreviousShifter]
642+
properties:
643+
shift: { $ref: '#/components/schemas/Shift' }
644+
issuesLogs:
645+
type: array
646+
description: Log entries of the shift carrying the tags of the shift type, EoS reports excluded (see the Logs resource).
647+
items: { type: object, additionalProperties: true }
648+
typeSpecific:
649+
type: [object, 'null']
650+
description: Depends on the shift type, see the operation description.
651+
properties:
652+
environments: { type: array, description: 'ECS shift only.', items: { type: object, additionalProperties: true } }
653+
runs:
654+
type: object
655+
description: QC/PDP and SL shifts only. Runs of the shift grouped by run definition.
656+
additionalProperties: { type: array, items: { type: object, additionalProperties: true } }
657+
tagsCounters:
658+
type: object
659+
description: SL shift only. Number of root logs of the shift per tag text, EoS reports excluded.
660+
additionalProperties: { type: integer }
661+
infoFromPreviousShifter:
662+
type: object
663+
description: The "For next shifter" section of the EoS report of the previous shift. Exactly one of the properties is set.
664+
properties:
665+
value: { type: string }
666+
errorMessage: { type: string, description: 'Why nothing could be retrieved (no report, several reports, empty section...).' }
667+
ShiftDataResponse:
668+
type: object
669+
required: [data]
670+
properties:
671+
data: { $ref: '#/components/schemas/ShiftData' }

‎lib/server/controllers/shift.controller.js‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,14 @@ const { shiftService } = require('../services/shift/ShiftService.js');
1515
const { updateExpressResponseFromNativeError } = require('../express/updateExpressResponseFromNativeError.js');
1616
const { GetShiftDataDto } = require('../../domain/dtos/shift/GetShiftDataDto.js');
1717

18-
// eslint-disable-next-line jsdoc/require-param
1918
/**
20-
* Route to fetch shift data
19+
* Route to fetch the data of the pending shift of the calling user
20+
*
21+
* @param {Object} request The *request* object represents the HTTP request and has properties for the request query
22+
* string, parameters, body, HTTP headers, and so on.
23+
* @param {Object} response The *response* object represents the HTTP response that an Express app sends when it gets an
24+
* HTTP request.
25+
* @returns {Promise<void>} resolves once the response has been sent
2126
*/
2227
const getShiftDataHandler = async (request, response) => {
2328
const requestDto = await dtoValidator(GetShiftDataDto, request, response);

0 commit comments

Comments
 (0)