-
Notifications
You must be signed in to change notification settings - Fork 21
[O2B-1506] LHCfills run duration filter #2038
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
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
1bdf8d0
637ad11
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 |
|---|---|---|
|
|
@@ -44,8 +44,10 @@ class GetAllLhcFillsUseCase { | |
|
|
||
| const queryBuilder = new QueryBuilder(); | ||
|
|
||
| let associatedStatisticsRequired = false; | ||
|
|
||
| if (filter) { | ||
| const { hasStableBeams, fillNumbers, beamDuration } = filter; | ||
| const { hasStableBeams, fillNumbers, beamDuration, runDuration } = filter; | ||
| if (hasStableBeams) { | ||
| // For now, if a stableBeamsStart is present, then a beam is stable | ||
| queryBuilder.where('stableBeamsStart').not().is(null); | ||
|
|
@@ -62,6 +64,22 @@ class GetAllLhcFillsUseCase { | |
| : queryBuilder.where('fillNumber').oneOf(...finalFillnumberList); | ||
| } | ||
| } | ||
|
|
||
| // Run duration filter and corresponding operator. | ||
| if (runDuration?.limit !== undefined && runDuration?.operator) { | ||
| associatedStatisticsRequired = true; | ||
| // 00:00:00 aka 0 value is saved in the DB as null (bookkeeping.fill_statistics.runs_coverage) | ||
| if ((runDuration.operator === '>=' || runDuration.operator === '<=') && Number(runDuration.limit) === 0) { | ||
| // Include 00:00:00 = 0 = null AND everything above 00:00:00 which is more or less than 0. | ||
| queryBuilder.whereAssociation('statistics', 'runsCoverage').applyOperator(runDuration.operator, 0); | ||
| queryBuilder.whereAssociation('statistics', 'runsCoverage').applyOperator('=', null); | ||
| } else if (Number(runDuration.limit) === 0) { | ||
|
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. Operators > and < are not handled here I think properly when limit is 0. They will get caught in the 1st else if and be compared with null which won't work with > and <. Need another condition statement if > or < and limit is 0 then apply operator on 0. And add the extra test cases. |
||
| queryBuilder.whereAssociation('statistics', 'runsCoverage').applyOperator(runDuration.operator, null); | ||
| } else { | ||
| queryBuilder.whereAssociation('statistics', 'runsCoverage').applyOperator(runDuration.operator, runDuration.limit); | ||
| } | ||
| } | ||
|
|
||
| // Beam duration filter, limit and corresponding operator. | ||
| if (beamDuration?.limit !== undefined && beamDuration?.operator) { | ||
| queryBuilder.where('stableBeamsDuration').applyOperator(beamDuration.operator, beamDuration.limit); | ||
|
|
@@ -74,6 +92,11 @@ class GetAllLhcFillsUseCase { | |
| where: { definition: RunDefinition.PHYSICS }, | ||
| required: false, | ||
| }); | ||
| queryBuilder.include({ | ||
| association: 'statistics', | ||
| required: associatedStatisticsRequired, | ||
| }); | ||
|
|
||
| queryBuilder.orderBy('fillNumber', 'desc'); | ||
| queryBuilder.limit(limit); | ||
| queryBuilder.offset(offset); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
I am unsure at the moment whether this is the best solution to the be able to join 2 applyOperators. Maybe that is not solution at all and could modify apply operator that if object is passed i.e raw sequalize operator logic then you can pass in all in one go to the method instead of twice and this extra changes to be able to do twice.