-
Notifications
You must be signed in to change notification settings - Fork 21
[O2B-1508] LHCfills beam types filter #2045
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
057c235
a7a9eda
2648f1c
094e6c5
da7ff37
ee72512
96a04c0
6fa4034
17ea048
695622b
87bee89
5a18d9e
4c530ef
51b50d9
c0c8559
9934e56
f247a6f
9b67281
ea0880f
46d4ae8
91e350c
e95c847
5077fec
9130c87
0d0986e
804cd4c
2f5932a
1e3f503
de7d95b
cafcba1
4c28a84
a34340e
9921652
1c2fffb
d40bd5c
d3c1ead
fe5f6c7
7628bca
a533088
36bdd8d
b7fe810
0751b57
6f77e0c
618daa1
8701246
e64d28f
19269b8
18ea386
fd055ca
6a47048
8e82b34
e5bbc05
668f90e
a047600
7ce2103
f113473
16246a0
d75c03e
bd1b836
9e3bc30
3d2f665
a04fac2
ff540af
9e4e68c
0af9bdf
45acea2
fd057c2
4a4ed6d
ce6fb68
eca4ffa
133aa01
191fd52
754f669
15e6a39
78a2d12
7b4f035
1bdf8d0
6a516b8
2aec67f
637ad11
4e68523
8b726c6
516bbbc
c6e6867
475c273
e301404
92c7f4f
8797eb6
17f361e
cf3ebb0
38a9041
8ff1398
a0a8a98
466a839
817164b
1ec3173
54dee2f
2050c41
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| /** | ||
| * @license | ||
| * Copyright CERN and copyright holders of ALICE Trg. This software is | ||
| * distributed under the terms of the GNU General Public License v3 (GPL | ||
| * Version 3), copied verbatim in the file "COPYING". | ||
| * | ||
| * See http://alice-Trg.web.cern.ch/license for full licensing information. | ||
| * | ||
| * In applying this license CERN does not waive the privileges and immunities | ||
| * granted to it by virtue of its status as an Intergovernmental Organization | ||
| * or submit itself to any jurisdiction. | ||
| */ | ||
|
|
||
| import { beamTypesProvider } from '../../../services/beamTypes/beamTypesProvider.js'; | ||
| import { SelectionFilterModel } from '../common/filters/SelectionFilterModel.js'; | ||
|
|
||
| /** | ||
| * Beam type filter model | ||
| */ | ||
| export class BeamTypeFilterModel extends SelectionFilterModel { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps not for this PR today as it is the sole case, but to keep in mind for future usecases, we should extract this into something like |
||
| /** | ||
| * Constructor | ||
NarrowsProjects marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| */ | ||
| constructor() { | ||
| super({ multiple: true, allowEmpty: true }); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SelectionFilterModel's constructor does not have the
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After testing it, it works just as well with. |
||
|
|
||
| beamTypesProvider.items$.observe(() => { | ||
| beamTypesProvider.items$.getCurrent().apply({ | ||
| Success: (types) => { | ||
| const beamTypes = types.map((type) => ({ value: type.beam_type })); | ||
| this._selectionModel.setAvailableOptions(beamTypes); | ||
| }, | ||
| }); | ||
| }); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| /** | ||
| * @license | ||
| * Copyright CERN and copyright holders of ALICE O2. This software is | ||
| * distributed under the terms of the GNU General Public License v3 (GPL | ||
| * Version 3), copied verbatim in the file "COPYING". | ||
| * | ||
| * See http://alice-o2.web.cern.ch/license for full licensing information. | ||
| * | ||
| * In applying this license CERN does not waive the privileges and immunities | ||
| * granted to it by virtue of its status as an Intergovernmental Organization | ||
| * or submit itself to any jurisdiction. | ||
| */ | ||
|
|
||
| import { checkboxes } from '../common/filters/checkboxFilter.js'; | ||
|
|
||
| /** | ||
| * Renders a list of checkboxes that lets the user look for beam types | ||
| * | ||
| * @param {BeamTypeFilterModel} beamTypeFilterModel beamTypeFilterModel | ||
| * @return {Component} the filter | ||
| */ | ||
| export const beamTypeFilter = (beamTypeFilterModel) => | ||
| checkboxes( | ||
| beamTypeFilterModel.selectionModel, | ||
| { selector: 'beam-types' }, | ||
| ); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| /** | ||
| * @license | ||
| * Copyright CERN and copyright holders of ALICE O2. This software is | ||
| * distributed under the terms of the GNU General Public License v3 (GPL | ||
| * Version 3), copied verbatim in the file "COPYING". | ||
| * | ||
| * See http://alice-o2.web.cern.ch/license for full licensing information. | ||
| * | ||
| * In applying this license CERN does not waive the privileges and immunities | ||
| * granted to it by virtue of its status as an Intergovernmental Organization | ||
| * or submit itself to any jurisdiction. | ||
| */ | ||
|
|
||
| import { getRemoteData } from '../../utilities/fetch/getRemoteData.js'; | ||
| import { RemoteDataProvider } from '../RemoteDataProvider.js'; | ||
|
|
||
| /** | ||
| * Service class to fetch beams types from the backend | ||
| */ | ||
| export class BeamTypesProvider extends RemoteDataProvider { | ||
| /** | ||
| * @inheritDoc | ||
| */ | ||
| async getRemoteData() { | ||
| const { data } = await getRemoteData('/api/lhcFills/beamTypes'); | ||
| return data; | ||
| } | ||
| } | ||
|
|
||
| export const beamTypesProvider = new BeamTypesProvider(); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| /** | ||
| * @license | ||
| * Copyright CERN and copyright holders of ALICE O2. This software is | ||
| * distributed under the terms of the GNU General Public License v3 (GPL | ||
| * Version 3), copied verbatim in the file "COPYING". | ||
| * | ||
| * See http://alice-o2.web.cern.ch/license for full licensing information. | ||
| * | ||
| * In applying this license CERN does not waive the privileges and immunities | ||
| * granted to it by virtue of its status as an Intergovernmental Organization | ||
| * or submit itself to any jurisdiction. | ||
| */ | ||
|
|
||
| const { repositories: { LhcFillRepository }, sequelize } = require('../../../database'); | ||
| const { Op } = require('sequelize'); | ||
|
|
||
| /** | ||
| * Return the a list of unique beam types which is built from the runs data | ||
| * | ||
| * @returns {Promise<SequelizeBeamType[]>} Promise resolving with the list of unique beam types | ||
| */ | ||
| exports.getAllBeamTypes = async () => { | ||
| const beamTypes = await LhcFillRepository.findAll({ | ||
| attributes: [[sequelize.fn('DISTINCT', sequelize.col('beam_type')), 'beam_type']], | ||
| where: { | ||
| beam_type: { | ||
| [Op.ne]: null, | ||
| }, | ||
| }, | ||
| order: [['beam_type', 'ASC']], | ||
| raw: true, | ||
| }); | ||
| return beamTypes; | ||
| }; |
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps it would be good to add tests for the newly added endpoint as well? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that we send this input to the DB, might be useful to apply some kind of restrictions?
For example we do know that all beam types are in format
<beam>-<beam>and as per the DB restrictions, cannot be larger than 64 chars.We can also safely assume that PROTON-PROTON is the largest, as we know from LHC that other elements use their chemical acronym (Pb, O, Ne, etc)