Repository navigation
Conversation
The templates table holds the name, title and description of a template. The template_modules table holds its modules in presentation order, each with a module type, an optional slide title and its options as JSON. Deleting a template deletes its modules, and each position is used once per template. The seeder adds two example templates for the tests and for development.
GET /api/templates lists the templates sorted by title, without their modules. GET /api/templates/:templateId returns one template with its modules in presentation order, or a 404 naming the id. The endpoints follow the layers of the run types endpoints.
openapi.yaml is written by hand, and API.md and index.html are generated from it with npm run docs:api.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## alice-insights/dev #2322 +/- ##
======================================================
+ Coverage 46.00% 46.21% +0.20%
======================================================
Files 1070 1091 +21
Lines 17610 17922 +312
Branches 3261 3307 +46
======================================================
+ Hits 8102 8283 +181
- Misses 9508 9639 +131 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…zone and keep the period when the week is emptied
…selection changes
…entation was made
8fecbec to
3e9b487
Compare
Remzi1993
left a comment
There was a problem hiding this comment.
5 high priority issues and 2 non-blocking comments.
| /** @type {import('sequelize-cli').Migration} */ | ||
| module.exports = { | ||
| up: async (queryInterface, Sequelize) => queryInterface.sequelize.transaction(async (transaction) => { | ||
| await queryInterface.createTable('presentation_templates', { |
There was a problem hiding this comment.
Could we keep the migration from #2308 and add a follow-up migration that renames the existing tables and columns?
I tested the merge order described in this PR with the two seeded templates and a custom template containing two modules. The migration completed successfully, but the template list came back empty. All three templates and their modules were still in the old tables.
Since #2308 is meant to merge first, could we add an upgrade test that verifies the same template IDs, titles and ordered modules are still available afterwards? The fresh-database path already works.
Status: High priority
Reason: After upgrading from #2308, the template picker is empty. Existing templates and their modules remain in the old tables and become inaccessible through the page.
| get period() { | ||
| const { value: from } = this.timeRangeModel.fromTimeInputModel; | ||
| const { value: to } = this.timeRangeModel.toTimeInputModel; | ||
| return { from: from === null ? null : asGenevaTime(from), to: to === null ? null : asGenevaTime(to) }; |
There was a problem hiding this comment.
I tried entering 8 March 2026, 02:30–03:30 Geneva time in the Presentations page. Generate was enabled in a Zurich browser and disabled in a New York browser.
Both times exist in Geneva. New York skips 02:30 that morning, so the browser has already changed the start to 03:30 by the time asGenevaTime() receives it. The start and end then become identical.
Could we convert the raw datetime-local fields directly to Geneva time and cover this one-hour selection in the browser tests?
Status: High priority
Reason: A coordinator can enter a valid Geneva reporting period and still be unable to generate the PDF because of their browser’s time zone.
| if (e.target.value !== '') { | ||
| timeRangeFilterModel.setValue( | ||
| { | ||
| from: getStartOfWeek(e.target.value).getTime(), |
There was a problem hiding this comment.
The Monday calculation works for week 47. I found one more case at New Year: with the clock fixed at 31 December 2026, 23:30 UTC, selecting Week 1 gave me 4–11 January 2027 in Zurich and 29 December 2025–5 January 2026 in Los Angeles.
getStartOfWeek() still takes the current year from the browser when no year is passed. Could the Presentations page pass the Geneva year explicitly for both ends of the week and use that year for the picker’s week limit too?
Status: High priority
Reason: Two coordinators making the same Week 1 selection can generate reports for periods a whole year apart.
|
|
||
| if (response.status !== 200) { | ||
| const detail = await readDetail(response); | ||
| logger.warnMessage(`ALICE Insights answered ${response.status} for template ${templateId}${detail ? `: ${detail}` : ''}`); |
There was a problem hiding this comment.
Could we log the status and template ID, and sanitize the upstream detail before including it in the log? The generator’s unknown-module response includes the module type from the stored template. A line break in that value therefore becomes a line break in Bookkeeping’s log too.
For an unexpected status such as 500, the status and template ID are enough to trace the failed request. For a known status, a bounded, single-line explanation would preserve the useful detail.
Status: High priority
Reason: One failed request can produce multiple log lines, breaking the PR’s one-line logging requirement and making it harder to identify which text belongs to that failure.
| const startOfYear = getStartOfYear(year); | ||
| // 0 is Sunday, but we want it to be Monday, so cycle every indices by -1 (add 7 before removing 1 then modulo 7 to avoid negatives) | ||
| const weekDay = (startOfYear.getDay() + 6) % 7; | ||
| const weekDay = (startOfYear.getUTCDay() + 6) % 7; |
There was a problem hiding this comment.
Could we add a week-count regression test alongside this UTC weekday fix? In a New York browser, getWeeksCount(2029) changed from 52 to 53. The extra Monday is 31 December 2029, which belongs to ISO week 1 of 2030.
This affects every page using the shared picker. Taking the ISO week number of 28 December would give the correct final week for both 52-week and 53-week years.
Status: High priority
Reason: The shared picker offers a week that does not exist in the selected ISO year. This affects every page that uses the picker.
| const explanation = () => h( | ||
| 'p.mv0#presentations-explanation', | ||
| 'Choose a period and a template to generate a presentation as a PDF. A presentation covers every LHC fill with ' | ||
| + 'stable beams in the period. Each fill is shown in full, with all its PHYSICS runs, so the slides can include ' |
There was a problem hiding this comment.
Could we reword “Each fill is shown in full, with all its PHYSICS runs”? In the March 2022 report, the calendar explains why it left out four runs.
I’d suggest: “The report selects fills whose stable beams overlap your chosen period. Their PHYSICS runs can extend before or after that period. The fill calendar tells you when it leaves a run out and why.”
Let's make things more explicit and clear. So we make the expectations clear beforehand and what people can expect when they chose a period and what happens when runs are outside the chosen period.
See example:
March 2022 example.pdf
Status: Non-blocking
Reason: The introduction overpromises what the calendar displays. The generated calendar already tells the reader how many runs it omitted and why.
| schema: { type: string, format: binary } | ||
| '400': { $ref: '#/components/responses/ValidationError' } | ||
| '401': { description: A valid Bookkeeping user session is required. } | ||
| '422': { description: 'ALICE Insights rejected the template or period. The detail of this and every other error of ALICE Insights is the sentence with which it explains why.' } |
There was a problem hiding this comment.
Document which errors pass through:
Could we narrow “every other error” to the statuses the proxy actually forwards? For 401, 422, 502 and 503, the page can show the generator’s explanation. An upstream 500 becomes Bookkeeping’s generic 502. It would help callers if the API docs described both outcomes.
Status: Non-blocking
Reason: The API documentation overstates which generator errors pass through. The proxy still returns a handled error to the page.
I DON'T have JIRA ticket
What this PR does
These changes come from running the three parts as one path: the presentation templates (#2308), the Presentations page (#2316) and the generation service. Both pull requests follow the agreements of their own task, so nothing here is a mistake in them.
presentation_templatesandpresentation_template_modules, and the endpoints areGET /api/presentationTemplatesandGET /api/presentationTemplates/{presentationTemplateId}. Template on its own is a general word in Bookkeeping. The code, the tests and the API documentation follow the same name, and the page reads the new endpoint.optionscolumn. A module of a template has a position, a type and a title. No module of the generation service has a setting.getStartOfWeekreads the weekday of its UTC date in UTC. Read on the local clock, a browser west of UTC gets a week that starts a day late. An emptied week field leaves the period as it is. Both hold for every page with the period picker.Where to look
lib/database/models/presentationTemplate.jsandlib/server/routers/presentationTemplates.router.js.lib/public/views/Presentations/genevaTime.jsandPresentationsPageModel.js.lib/public/utilities/dateUtils.mjsandlib/public/components/Filters/common/filters/timeRangeFilter.js.lib/server/services/presentation/generatePresentation.js.lib/public/views/Presentations/PresentationsPage.js.test/api/presentationTemplates.test.js,test/api/presentations.test.js,test/lib/public/utilities/dateUtils.test.jsandtest/public/presentations/overview.test.js, which runs with a browser in New York and, for the day the clocks go forward, in Auckland.The commits
Each commit passes the linter and the test suites it touches.
Rename templates to presentation templates and drop the unused module options: points 1 and 2.Start the week of the period picker on the same Monday in every time zone and keep the period when the week is emptied: point 4.Read the period as Geneva time and drop a finished download when the selection changes: points 3 and 5.Show the error sentence of the generation service and log why no presentation was made: points 6 and 7.Explain on the Presentations page which fills and runs a presentation covers: point 8.How to try it
npm run sequelize -- db:seed:all), and start the generation service.Notable changes for users:
Notable changes for developers:
TemplateisPresentationTemplatein models, adapters, repository, service, DTOs and endpoints. The fieldtemplateIdofPOST /api/presentationskeeps its name.lib/public/views/Presentations/genevaTime.js.getStartOfWeekgives the same Monday in every time zone, and the week field of the period picker ignores an empty value.Changes made to the database:
presentation_templatesandpresentation_template_modules, without theoptionscolumn. A local database that ran the migration of Add storage and read endpoints for presentation templates #2308 needs a fresh start.