Skip to content

Connect the Presentations page, the presentation templates and the generation service - #2322

Draft
kaymeer wants to merge 15 commits into
alice-insights/devfrom
alice-insights/connect-presentations
Draft

kaymeer wants to merge 15 commits into
alice-insights/devfrom
alice-insights/connect-presentations

Conversation

@kaymeer

@kaymeer kaymeer commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

ALICE Insights project. This pull request is part of ALICE Insights, a project by students of the Amsterdam University of Applied Sciences (AUAS) for ALICE. It builds on #2308 and #2316 and is merged after them, into the project's base branch alice-insights/dev, not main.

Merge order. This branch holds the commits of #2308 and #2316. Until both are merged, the diff shows their changes too, and this pull request stays a draft so it cannot be merged before them. The last five commits are the ones to review.

I DON'T have JIRA ticket

  • explain what this PR does
  • if it is a new feature, explain how you plan to use it
  • tests are added
  • documentation was updated or added

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.

  1. The name presentation template. The tables are presentation_templates and presentation_template_modules, and the endpoints are GET /api/presentationTemplates and GET /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.
  2. No options column. A module of a template has a position, a type and a title. No module of the generation service has a setting.
  3. The period is in Geneva time. The dates and times of the period picker mean Geneva time for every user, whatever the time zone of the browser, and the label says "Period (Geneva time)". The slides show days in Geneva time, so a week is Monday 00:00 up to Monday 00:00 in Geneva.
  4. The week of the period picker starts on the same Monday in every time zone. getStartOfWeek reads 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.
  5. A finished presentation belongs to its template and period. Another template or period discards the finished download or the error of the request before it.
  6. The page shows why no presentation was made. The generation service explains every error in a sentence written for the user. Bookkeeping passes that sentence on, and uses its own only when the service gives none or cannot be reached. Add a Presentations page to generate PDFs #2316 shows Bookkeeping's own sentence for every error and has a test for that. That test is not part of this branch, because the sentence of the service says what the user can change, such as the period.
  7. The cause in the log. A request that gives no PDF writes one line to Bookkeeping's log: the answer of the generation service, or that it could not be reached at its address. Bookkeeping puts no token in the line: it holds the status, the template ID and the sentence of the service.
  8. The page says what a presentation covers. One paragraph under the title: a presentation covers every LHC fill with stable beams in the period, each in full with all its PHYSICS runs, so the slides can include time before and after the period.

Where to look

  • Points 1 and 2: the files of Add storage and read endpoints for presentation templates #2308 with their names after this pull request, such as lib/database/models/presentationTemplate.js and lib/server/routers/presentationTemplates.router.js.
  • Points 3 and 5: lib/public/views/Presentations/genevaTime.js and PresentationsPageModel.js.
  • Point 4: lib/public/utilities/dateUtils.mjs and lib/public/components/Filters/common/filters/timeRangeFilter.js.
  • Points 6 and 7: lib/server/services/presentation/generatePresentation.js.
  • Point 8: lib/public/views/Presentations/PresentationsPage.js.
  • Tests: test/api/presentationTemplates.test.js, test/api/presentations.test.js, test/lib/public/utilities/dateUtils.test.js and test/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.

  1. Rename templates to presentation templates and drop the unused module options: points 1 and 2.
  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.
  3. Read the period as Geneva time and drop a finished download when the selection changes: points 3 and 5.
  4. Show the error sentence of the generation service and log why no presentation was made: points 6 and 7.
  5. Explain on the Presentations page which fills and runs a presentation covers: point 8.

How to try it

  1. Start Bookkeeping from this branch with a fresh database and the example templates (npm run sequelize -- db:seed:all), and start the generation service.
  2. Open Presentations and choose week 47 in the period picker. The picker shows Monday 00:00 to Monday 00:00.
  3. Generate the presentation. The title slide reads "16 to 22 November 2026".
  4. Choose a period of two months and generate. The page shows "The period can be at most 31 days long."
  5. Stop the generation service and generate again. Bookkeeping's log has the line "ALICE Insights could not be reached at ...".

Notable changes for users:

  • The period of a presentation is in Geneva time, and the page says so.
  • The page shows why a presentation could not be made.
  • The page says which fills and runs a presentation covers.
  • On every page with the period picker, a week starts on Monday for a browser west of UTC.

Notable changes for developers:

  • Template is PresentationTemplate in models, adapters, repository, service, DTOs and endpoints. The field templateId of POST /api/presentations keeps its name.
  • New lib/public/views/Presentations/genevaTime.js.
  • getStartOfWeek gives the same Monday in every time zone, and the week field of the period picker ignores an empty value.

Changes made to the database:

kaymeer and others added 10 commits October 28, 2026 21:08
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.
@kaymeer
kaymeer requested a review from Remzi1993 November 25, 2026 22:19
@codecov

codecov Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 57.82748% with 132 lines in your changes missing coverage. Please review.
✅ Project coverage is 46.21%. Comparing base (743fe7f) to head (3e9b487).

Files with missing lines Patch % Lines
...blic/views/Presentations/PresentationsPageModel.js 0.00% 86 Missing ⚠️
...ib/public/views/Presentations/PresentationsPage.js 0.00% 20 Missing ⚠️
lib/public/views/Presentations/genevaTime.js 0.00% 14 Missing ⚠️
lib/public/Model.js 0.00% 5 Missing ⚠️
...v1/20261028100000-create-presentation-templates.js 62.50% 3 Missing ⚠️
...mponents/Filters/common/filters/timeRangeFilter.js 0.00% 3 Missing ⚠️
...er/controllers/presentationTemplates.controller.js 94.73% 1 Missing ⚠️
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.
📢 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.

@kaymeer
kaymeer force-pushed the alice-insights/connect-presentations branch from 8fecbec to 3e9b487 Compare November 25, 2026 23:09
@Remzi1993
Remzi1993 requested a review from graduta November 27, 2026 14:13

@Remzi1993 Remzi1993 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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', {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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) };

@Remzi1993 Remzi1993 Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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(),

@Remzi1993 Remzi1993 Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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}` : ''}`);

@Remzi1993 Remzi1993 Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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;

@Remzi1993 Remzi1993 Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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 '

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.' }

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.

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

None yet

Development

Successfully merging this pull request may close these issues.

2 participants