Skip to content

Commit 64a1438

Browse files
authored
[O2B-1240] Display only physical productions by default and adds filtering for 'test' and 'debug' productions display (#1940)
* add logic on backend * wip * wip * add filter * user enum * refactor WIP * w * fix sorting * cleanup * api test * api test * ui test * fix * fix counting * fix test * refactor test * use getter * raw * refactor * refactor * cleanup * cleanup * cleanup * docs * fix tesT * fixeD
1 parent 3444017 commit 64a1438

25 files changed

Lines changed: 303 additions & 137 deletions

lib/database/seeders/20240112102011-data-passes.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,22 @@ module.exports = {
4646
updated_at: '2024-02-15 12:00:00',
4747
},
4848

49+
{
50+
id: 6,
51+
name: 'LHC22b_test',
52+
lhc_period_id: 2,
53+
created_at: '2024-02-15 12:00:00',
54+
updated_at: '2024-02-15 12:00:00',
55+
},
56+
57+
{
58+
id: 7,
59+
name: 'LHC22b_debug',
60+
lhc_period_id: 2,
61+
created_at: '2024-02-15 12:00:00',
62+
updated_at: '2024-02-15 12:00:00',
63+
},
64+
4965
/** LHC22a (PbPb) */
5066
{
5167
id: 3,
@@ -111,6 +127,23 @@ module.exports = {
111127
created_at: '2024-02-15 12:00:00',
112128
updated_at: '2024-02-15 12:00:00',
113129
},
130+
131+
{
132+
id: 6,
133+
description: 'test',
134+
data_pass_id: 6,
135+
created_at: '2024-02-15 12:00:00',
136+
updated_at: '2024-02-15 12:00:00',
137+
},
138+
139+
{
140+
id: 7,
141+
description: 'debug',
142+
data_pass_id: 7,
143+
created_at: '2024-02-15 12:00:00',
144+
updated_at: '2024-02-15 12:00:00',
145+
},
146+
114147
], { transaction }),
115148

116149
await queryInterface.bulkInsert('data_pass_version_status_history', [
@@ -197,6 +230,24 @@ module.exports = {
197230
created_at: '2024-02-15 12:30:00',
198231
updated_at: '2024-02-15 12:30:00',
199232
},
233+
234+
/** Data pass version of LHC22b_test */
235+
{
236+
id: 11,
237+
data_pass_version_id: 6,
238+
status: DataPassVersionStatus.RUNNING,
239+
created_at: '2024-02-15 12:30:00',
240+
updated_at: '2024-02-15 12:30:00',
241+
},
242+
243+
/** Data pass version of LHC22b_debug */
244+
{
245+
id: 12,
246+
data_pass_version_id: 7,
247+
status: DataPassVersionStatus.RUNNING,
248+
created_at: '2024-02-15 12:30:00',
249+
updated_at: '2024-02-15 12:30:00',
250+
},
200251
], { transaction }),
201252

202253
await queryInterface.bulkInsert('data_passes_runs', [
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* @license
3+
* Copyright 2019-2020 CERN and copyright holders of ALICE O2.
4+
* See http://alice-o2.web.cern.ch/copyright for details of the copyright holders.
5+
* All rights not expressly granted are reserved.
6+
*
7+
* This software is distributed under the terms of the GNU General Public
8+
* License v3 (GPL Version 3), copied verbatim in the file "COPYING".
9+
*
10+
* In applying this license CERN does not waive the privileges and immunities
11+
* granted to it by virtue of its status as an Intergovernmental Organization
12+
* or submit itself to any jurisdiction.
13+
*/
14+
15+
const NonPhysicsProductionsNamesWords = Object.freeze({
16+
TEST: 'test',
17+
DEBUG: 'debug',
18+
});
19+
20+
module.exports.NonPhysicsProductionsNamesWords = NonPhysicsProductionsNamesWords;
21+
22+
module.exports.NON_PHYSICS_PRODUCTIONS_NAMES_WORDS = Object.values(NonPhysicsProductionsNamesWords);

lib/public/components/Filters/common/FilteringModel.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* or submit itself to any jurisdiction.
1212
*/
1313

14+
import { expandQueryLikeNestedKey } from '../../../utilities/expandNestedKey.js';
1415
import { Observable } from '/js/src/index.js';
1516

1617
/**
@@ -38,12 +39,17 @@ export class FilteringModel extends Observable {
3839
/**
3940
* Reset the filters
4041
*
42+
* @param {boolean} [notify=false] if true the model notifies its observers
4143
* @return {void}
4244
*/
43-
reset() {
45+
reset(notify = false) {
4446
for (const model of this._filterModels) {
4547
model.reset();
4648
}
49+
50+
if (notify) {
51+
this.notify();
52+
}
4753
}
4854

4955
/**
@@ -52,13 +58,14 @@ export class FilteringModel extends Observable {
5258
* @return {object} the normalized values
5359
*/
5460
get normalized() {
55-
const ret = {};
61+
const normalizedFilters = {};
5662
for (const [filterKey, filter] of Object.entries(this._filters)) {
5763
if (filter && !filter.isEmpty) {
58-
ret[filterKey] = filter.normalized;
64+
normalizedFilters[filterKey] = filter.normalized;
5965
}
6066
}
61-
return ret;
67+
68+
return expandQueryLikeNestedKey(normalizedFilters);
6269
}
6370

6471
/**

lib/public/components/Filters/common/filters/TextTokensFilterModel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export class TextTokensFilterModel extends FilterModel {
6363
* States if the filter has been filled
6464
* @return {boolean} true if the filter is empty
6565
*/
66-
isEmpty() {
66+
get isEmpty() {
6767
return this._raw.length === 0;
6868
}
6969

lib/public/components/Filters/common/filtersPanelPopover.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const filtersToggleContent = (
4545
{
4646
onclick: () => filteringModel.resetFiltering
4747
? filteringModel.resetFiltering()
48-
: filteringModel.reset(),
48+
: filteringModel.reset(true),
4949
disabled: !filteringModel.isAnyFilterActive(),
5050
},
5151
'Reset all filters',
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* @license
3+
* Copyright 2019-2020 CERN and copyright holders of ALICE O2.
4+
* See http://alice-o2.web.cern.ch/copyright for details of the copyright holders.
5+
* All rights not expressly granted are reserved.
6+
*
7+
* This software is distributed under the terms of the GNU General Public
8+
* License v3 (GPL Version 3), copied verbatim in the file "COPYING".
9+
*
10+
* In applying this license CERN does not waive the privileges and immunities
11+
* granted to it by virtue of its status as an Intergovernmental Organization
12+
* or submit itself to any jurisdiction.
13+
*/
14+
15+
export const NonPhysicsProductionsNamesWords = Object.freeze({
16+
TEST: 'test',
17+
DEBUG: 'debug',
18+
});
19+
20+
export const NON_PHYSICS_PRODUCTIONS_NAMES_WORDS = Object.values(NonPhysicsProductionsNamesWords);
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
* @license
3+
* Copyright CERN and copyright holders of ALICE O2. This software is
4+
* distributed under the terms of the GNU General Public License v3 (GPL
5+
* Version 3), copied verbatim in the file "COPYING".
6+
*
7+
* See http://alice-o2.web.cern.ch/license for full licensing information.
8+
*
9+
* In applying this license CERN does not waive the privileges and immunities
10+
* granted to it by virtue of its status as an Intergovernmental Organization
11+
* or submit itself to any jurisdiction.
12+
*/
13+
14+
/**
15+
* Expand query-like formatted keys of a object { a[b][c]: x } to { a: { b: { c: x } } }
16+
*
17+
* @param {object} obj a object
18+
* @return {object} obj
19+
*/
20+
export function expandQueryLikeNestedKey(obj) {
21+
const result = {};
22+
23+
for (const nestedKey in obj) {
24+
const value = obj[nestedKey];
25+
const subKeys = nestedKey.split(/[[\]]/).filter(Boolean);
26+
27+
let currentNestedObj = result;
28+
for (let i = 0; i < subKeys.length; i++) {
29+
const key = subKeys[i];
30+
if (i === subKeys.length - 1) {
31+
currentNestedObj[key] = value;
32+
} else {
33+
if (!(key in currentNestedObj)) {
34+
currentNestedObj[key] = {};
35+
}
36+
currentNestedObj = currentNestedObj[key];
37+
}
38+
}
39+
}
40+
41+
return result;
42+
}

lib/public/view.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import { StatisticsPage } from './views/Statistics/StatisticsPage.js';
3434
import { LhcPeriodsOverviewPage } from './views/lhcPeriods/Overview/LhcPeriodsOverviewPage.js';
3535
import { RunsPerLhcPeriodOverviewPage } from './views/Runs/RunPerPeriod/RunsPerLhcPeriodOverviewPage.js';
3636
import { HomePage } from './views/Home/Overview/HomePage.js';
37-
import { DataPassesPerLhcPeriodOverviewPage } from './views/DataPasses/PerLhcPeriodOverview/DataPassesPerLhcPeriodOverviewView.js';
37+
import { DataPassesPerLhcPeriodOverviewPage } from './views/DataPasses/PerLhcPeriodOverview/DataPassesPerLhcPeriodOverviewPage.js';
3838
import { SimulationPassesPerLhcPeriodOverviewPage }
3939
from './views/SimulationPasses/PerLhcPeriodOverview/SimulationPassesPerLhcPeriodOverviewPage.js';
4040
import { DataPassesPerSimulationPassOverviewPage }

lib/public/views/DataPasses/ActiveColumns/dataPassesActiveColumns.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
* or submit itself to any jurisdiction.
1212
*/
1313

14-
import { textFilter } from '../../../components/Filters/common/filters/textFilter.js';
1514
import { frontLink } from '../../../components/common/navigation/frontLink.js';
1615
import { formatSizeInBytes } from '../../../utilities/formatting/formatSizeInBytes.js';
1716
import { formatItemsCount } from '../../../utilities/formatting/formatItemsCount.js';
@@ -20,6 +19,8 @@ import { sumNotNulls } from '../../../utilities/formatting/sumNotNulls.js';
2019
import { h } from '/js/src/index.js';
2120
import { formatDataPassName } from '../format/formatDataPassName.js';
2221
import { formatDataPassStatusHistory } from '../format/formatStatusHistory.js';
22+
import { checkboxes } from '../../../components/Filters/common/filters/checkboxFilter.js';
23+
import { rawTextFilter } from '../../../components/Filters/common/filters/rawTextFilter.js';
2324

2425
/**
2526
* List of active columns for a generic data passes table
@@ -34,9 +35,9 @@ export const dataPassesActiveColumns = {
3435
visible: true,
3536
sortable: true,
3637
format: (_, dataPass) => formatDataPassName(dataPass),
37-
filter: ({ nameFilterModel }) => textFilter(
38-
nameFilterModel,
39-
{ class: 'w-75 mt1', placeholder: 'e.g. LHC22a_apass1, ...' },
38+
filter: (filteringModel) => rawTextFilter(
39+
filteringModel.get('names'),
40+
{ classes: ['w-75', 'mt1'], placeholder: 'e.g. LHC22a_apass1, ...' },
4041
),
4142
balloon: true,
4243
classes: 'w-20',
@@ -90,15 +91,21 @@ export const dataPassesActiveColumns = {
9091
name: 'Reconstructed Events',
9192
format: (_, { versions }) => formatItemsCount(sumNotNulls(versions.map(({ reconstructedEventsCount }) => reconstructedEventsCount))),
9293
visible: true,
93-
sortable: true,
94+
sortable: false,
9495
classes: 'w-10',
9596
},
9697

9798
outputSize: {
9899
name: 'Output Size (B)',
99100
visible: true,
100101
format: (_, { versions }) => formatSizeInBytes(sumNotNulls(versions.map(({ outputSize }) => outputSize))),
101-
sortable: true,
102+
sortable: false,
102103
classes: 'w-10',
103104
},
105+
106+
nonPhysicsProductions: {
107+
name: 'Include nonphysics productions',
108+
filter: (filteringModel) => checkboxes(filteringModel.get('include[byName]').selectionModel),
109+
visible: false,
110+
},
104111
};
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/**
2+
* @license
3+
* Copyright CERN and copyright holders of ALICE O2. This software is
4+
* distributed under the terms of the GNU General Public License v3 (GPL
5+
* Version 3), copied verbatim in the file "COPYING".
6+
*
7+
* See http://alice-o2.web.cern.ch/license for full licensing information.
8+
*
9+
* In applying this license CERN does not waive the privileges and immunities
10+
* granted to it by virtue of its status as an Intergovernmental Organization
11+
* or submit itself to any jurisdiction.
12+
*/
13+
import { FilteringModel } from '../../components/Filters/common/FilteringModel.js';
14+
import { SelectionFilterModel } from '../../components/Filters/common/filters/SelectionFilterModel.js';
15+
import { TextTokensFilterModel } from '../../components/Filters/common/filters/TextTokensFilterModel.js';
16+
import { NON_PHYSICS_PRODUCTIONS_NAMES_WORDS } from '../../domain/enums/NonPhysicsProductionsNamesWords.js';
17+
import { OverviewPageModel } from '../../models/OverviewModel.js';
18+
19+
/**
20+
* Data Passes overview model
21+
*/
22+
export class DataPassesOverviewModel extends OverviewPageModel {
23+
/**
24+
* Constructor
25+
*/
26+
constructor() {
27+
super();
28+
this._filteringModel = new FilteringModel({
29+
names: new TextTokensFilterModel(),
30+
'include[byName]': new SelectionFilterModel({
31+
availableOptions: NON_PHYSICS_PRODUCTIONS_NAMES_WORDS.map((word) => ({ label: word.toUpperCase(), value: word })),
32+
}),
33+
});
34+
35+
this._filteringModel.visualChange$.bubbleTo(this);
36+
this._filteringModel.observe(() => {
37+
this._pagination.currentPage = 1;
38+
this.load();
39+
});
40+
}
41+
42+
/**
43+
* Return filter params of base model
44+
*
45+
* @return {object} filter
46+
*/
47+
getFilterParams() {
48+
return this._filteringModel.normalized;
49+
}
50+
51+
/**
52+
* Reset this model to its default
53+
*
54+
* @returns {void}
55+
*/
56+
reset() {
57+
this._filteringModel.reset();
58+
super.reset();
59+
}
60+
61+
/**
62+
* Return the filtering model
63+
*
64+
* @return {FilteringModel} the filtering model
65+
*/
66+
get filteringModel() {
67+
return this._filteringModel;
68+
}
69+
}

0 commit comments

Comments
 (0)