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 #2308 +/- ##
======================================================
+ Coverage 46.00% 46.32% +0.32%
======================================================
Files 1070 1084 +14
Lines 17610 17723 +113
Branches 3261 3266 +5
======================================================
+ Hits 8102 8211 +109
- Misses 9508 9512 +4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I DON'T have JIRA ticket
What this PR does
Adds presentation templates to Bookkeeping: two tables to store them, a seeder with two examples, and two endpoints to read them. A template is the content of a presentation: a name, a title, a description and an ordered list of content modules, each with its own settings. It holds no styling.
Tables
templatesid,name(unique),title,description(optional)template_modulesid,template_id(deleted with its template),position(unique per template, 0 is the first slide),type,title(optional),options(JSON)A module type names code in the ALICE Insights generation service that turns data into slides. Bookkeeping only stores which modules a template uses, in which order and with which settings. The same module type can appear in several templates, each time with its own title and settings.
Endpoints
GET /api/templatesid,name,titleanddescription, without modules. Not paginated, pagination parameters are rejectedGET /api/templates/:templateIdmodulesin presentation order, each withposition,type,titleandoptions. A 404 names the id, and an id that is not a positive number gets a 400Both are read endpoints for every signed-in user, like the other read endpoints.
Example templates (seeder)
The data modules show PHYSICS runs (
{"run_definitions": ["PHYSICS"]}).Design choices
Where to look
The PR has three commits, one per step:
migrations/v1/20261028100000-create-templates.jsseeders/20261028100000-templates.jsmodels/template.js,models/templateModule.js, their typedefs,models/index.jsrepositories/TemplateRepository.jsadapters/TemplateAdapter.js,adapters/TemplateModuleAdapter.jsservices/template/TemplateService.js,getAllTemplates.js,getTemplate.js,getTemplateOrFail.jsGetAllTemplatesDto.js,GetTemplateDto.js,templates.controller.js,templates.router.jstest/api/templates.test.js,test/lib/server/services/template/openapi.yaml, withAPI.mdandindex.htmlgenerated bynpm run docs:apiThe other changed files are the
index.jsfiles that register the new parts. The layers follow the run types endpoints.How we plan to use it
ALICE Insights builds presentations from Bookkeeping's data. Its generation service reads a template through these endpoints with the user's own token, and builds the presentation from the modules the template lists. A Presentations page in Bookkeeping will list the templates through
GET /api/templatesso the user can pick one. These parts follow in separate pull requests.How to try it
docker compose exec application npm run sequelize -- db:seed:allGET /api/templates?token=<token>returns both templates.GET /api/templates/1?token=<token>returns the Run Manager Weekly Report with its five modules.GET /api/templates/99?token=<token>returns a 404, andGET /api/templates/-1?token=<token>a 400.Notable changes for users:
Notable changes for developers:
TemplateandTemplateModule, withTemplate.hasMany(TemplateModule)asmodulesandTemplateModule.belongsTo(Template).TemplateRepository,TemplateAdapterandTemplateModuleAdapter, and theTemplateandTemplateModuleentities.TemplateServicewithgetAll()andgetOneOrFail(id), backed bygetAllTemplates,getTemplateandgetTemplateOrFail.GET /api/templatesandGET /api/templates/:templateId, withGetAllTemplatesDtoandGetTemplateDto, documented in the HTTP API documentation under Templates.20261028100000-templates.jswith two example templates.templates.test.js) and service tests (TemplateService.test.js). The unit, API and browser suites were run in docker and pass, and so doesnpm run lint.Changes made to the database:
templatesandtemplate_modules, created by the migration20261028100000-create-templates.js.template_modules.template_idreferencestemplates.idwithON DELETE CASCADE, and(template_id, position)is unique. No existing table changes.