Skip to content

Commit 7557b69

Browse files
[O2B-1103] Environment history occurrences histogram (#1328)
* [O2B-1103] implemented the environment history occurrences histogram * [O2B-1103] implemented changes requested in the API PR * [O2B-1103] additional fix for the PR changes * [O2B-1103] changed existing status acronyms in accordance to the RMreportW29_2023 * [O2B-1103] added a max displayed bin limit to the environmentHistoryOccurences chart --------- Co-authored-by: Martin Boulais <31805063+martinboulais@users.noreply.github.com>
1 parent eae424b commit 7557b69

7 files changed

Lines changed: 132 additions & 25 deletions

File tree

lib/public/domain/enums/statusAcronyms.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,11 @@
1313

1414
const statusAcronyms = {
1515
STANDBY: 'S',
16-
DEPLOYED: 'DL',
16+
DEPLOYED: 'D',
1717
CONFIGURED: 'C',
1818
RUNNING: 'R',
1919
ERROR: 'E',
20-
MIX: 'M',
21-
DESTROYED: 'DS',
20+
DESTROYED: 'X',
2221
};
2322

2423
export const STATUS_ACRONYMS = statusAcronyms;

lib/public/views/Environments/ActiveColumns/environmentsActiveColumns.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
import { formatTimestamp } from '../../../utilities/formatting/formatTimestamp.js';
1515
import { formatRunsList } from '../../Runs/format/formatRunsList.js';
16-
import { displayEnvironmentStatusHistory } from '../format/displayEnvironmentStatusHistory.js';
16+
import { displayEnvironmentStatusHistoryOverview } from '../format/displayEnvironmentStatusHistoryOverview.js';
1717
import { displayEnvironmentStatus } from '../format/displayEnvironmentStatus.js';
1818
import { infoLoggerButtonGroup } from '../../../components/common/selection/infoLoggerButtonGroup/infoLoggerButtonGroup.js';
1919

@@ -59,7 +59,7 @@ export const environmentsActiveColumns = {
5959
sortable: false,
6060
size: 'w-30',
6161
title: true,
62-
format: (_, environment) => displayEnvironmentStatusHistory(environment),
62+
format: (_, environment) => displayEnvironmentStatusHistoryOverview(environment),
6363
balloon: true,
6464
},
6565
runs: {

lib/public/views/Environments/format/displayEnvironmentStatusHistory.js

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,17 @@
1010
* granted to it by virtue of its status as an Intergovernmental Organization
1111
* or submit itself to any jurisdiction.
1212
*/
13-
import { h } from '/js/src/index.js';
13+
1414
import { STATUS_ACRONYMS } from '../../../domain/enums/statusAcronyms.js';
15-
import { coloredEnvironmentStatusComponent } from '../ColoredEnvironmentStatusComponent.js';
1615

1716
/**
18-
* Display the given environment's status history string
17+
* Display the given environment's status history as a string of acronyms
1918
*
20-
* @param {Environment} environment the environment for which status should be displayed
21-
* @return {vnode} the resulting component
19+
* @param {String} statusHistory the environment status history seperated by commas
20+
* @return {String} the abbreviated string representation of the environment status history
2221
*/
23-
export const displayEnvironmentStatusHistory = (environment) => {
24-
const { historyItems } = environment;
25-
26-
const statusHistory = historyItems
27-
.filter(({ status }) => status in STATUS_ACRONYMS)
28-
.map(({ status }) => ({ status, content: STATUS_ACRONYMS[status] }));
29-
30-
return h(
31-
'.flex-row',
32-
statusHistory.map((value, index) => h('.flex-row', [
33-
coloredEnvironmentStatusComponent(value.status, value.content),
34-
h('', index < statusHistory.length - 1 ? '-' : ''),
35-
])),
36-
);
37-
};
22+
export const displayEnvironmentStatusHistory = (statusHistory) =>
23+
statusHistory.split(',')
24+
.filter((status) => status in STATUS_ACRONYMS)
25+
.map((status) => STATUS_ACRONYMS[status])
26+
.join('');
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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 { h } from '/js/src/index.js';
14+
import { STATUS_ACRONYMS } from '../../../domain/enums/statusAcronyms.js';
15+
import { coloredEnvironmentStatusComponent } from '../ColoredEnvironmentStatusComponent.js';
16+
17+
/**
18+
* Display the given environment's status history string
19+
*
20+
* @param {Environment} environment the environment for which status should be displayed
21+
* @return {vnode} the resulting component
22+
*/
23+
export const displayEnvironmentStatusHistoryOverview = (environment) => {
24+
const { historyItems } = environment;
25+
26+
const statusHistory = historyItems
27+
.filter(({ status }) => status in STATUS_ACRONYMS)
28+
.map(({ status }) => ({ status, content: STATUS_ACRONYMS[status] }));
29+
30+
return h(
31+
'.flex-row',
32+
statusHistory.map((value, index) => h('.flex-row', [
33+
coloredEnvironmentStatusComponent(value.status, value.content),
34+
h('', index < statusHistory.length - 1 ? '-' : ''),
35+
])),
36+
);
37+
};

lib/public/views/Statistics/StatisticsPage.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { ChartDarkColors } from './chartColors.js';
2424
import { tagOccurrencesBarChartComponent } from './charts/tagOccurrencesBarChartComponent.js';
2525
import { timeRangeFilter } from '../../components/Filters/common/filters/timeRangeFilter.js';
2626
import { eorReasonOccurrencesBarChartComponent } from './charts/eorReasonOccurrencesBarChartComponent.js';
27+
import { environmentHistoryOccurrencesBarChartComponent } from './charts/environmentHistoryOccurrencesBarChartComponent.js';
2728
import { formatTimeRange } from '../../components/common/formatting/formatTimeRange.js';
2829
import spinner from '../../components/common/spinner.js';
2930
import errorAlert from '../../components/common/errorAlert.js';
@@ -57,6 +58,7 @@ export const StatisticsPage = ({ statisticsModel }) => {
5758
[STATISTICS_PANELS_KEYS.EFFICIENCY_PER_DETECTOR]: 'Detector efficiency',
5859
[STATISTICS_PANELS_KEYS.LOG_TAG_OCCURRENCES]: 'Tag occurrences in logs',
5960
[STATISTICS_PANELS_KEYS.EOR_REASON_OCCURRENCES]: 'End of run reason occurrences',
61+
[STATISTICS_PANELS_KEYS.ENVIRONMENT_HISTORY_OCCURRENCES]: 'Environment history occurrences',
6062
},
6163
{
6264
[STATISTICS_PANELS_KEYS.LHC_FILL_EFFICIENCY]: (remoteData) => remoteDataDisplay(remoteData, {
@@ -160,6 +162,12 @@ export const StatisticsPage = ({ statisticsModel }) => {
160162
h('.flex-grow.chart-box', eorReasonOccurrencesBarChartComponent(eorReasonOccurrences)),
161163
],
162164
}),
165+
[STATISTICS_PANELS_KEYS.ENVIRONMENT_HISTORY_OCCURRENCES]: (remoteData) => remoteDataDisplay(remoteData, {
166+
Success: (environmentHistoryOccurrences) => [
167+
h('h3', `Environment history occurrences - ${periodLabel}`),
168+
h('.flex-grow.chart-box', environmentHistoryOccurrencesBarChartComponent(environmentHistoryOccurrences)),
169+
],
170+
}),
163171
},
164172
{ panelClass: ['p2', 'g3', 'flex-column', 'flex-grow'] },
165173
),

lib/public/views/Statistics/StatisticsPageModel.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export const STATISTICS_PANELS_KEYS = {
2626
EFFICIENCY_PER_DETECTOR: 'efficiency-per-detector',
2727
LOG_TAG_OCCURRENCES: 'log-tag-occurrences',
2828
EOR_REASON_OCCURRENCES: 'eor-reasons-occurrences',
29+
ENVIRONMENT_HISTORY_OCCURRENCES: 'environment-history-occurrences',
2930
};
3031

3132
/**
@@ -166,6 +167,13 @@ class StatisticsTabbedPanelModel extends TabbedPanelModel {
166167
{ from: this._period.from, to: this._period.to },
167168
));
168169
break;
170+
case STATISTICS_PANELS_KEYS.ENVIRONMENT_HISTORY_OCCURRENCES:
171+
// eslint-disable-next-line max-len
172+
this._fetchEndpointForPanelData(buildUrl(
173+
'/api/statistics/environments/historyOccurrences',
174+
{ from: this._period.from, to: this._period.to },
175+
));
176+
break;
169177
case STATISTICS_PANELS_KEYS.EFFICIENCY_PER_DETECTOR:
170178
this._detectorEfficiencyTabModel.fetch();
171179
break;
@@ -193,6 +201,7 @@ class StatisticsTabbedPanelModel extends TabbedPanelModel {
193201
case STATISTICS_PANELS_KEYS.TIME_BETWEEN_RUNS_DISTRIBUTION:
194202
case STATISTICS_PANELS_KEYS.LOG_TAG_OCCURRENCES:
195203
case STATISTICS_PANELS_KEYS.EOR_REASON_OCCURRENCES:
204+
case STATISTICS_PANELS_KEYS.ENVIRONMENT_HISTORY_OCCURRENCES:
196205
return this._observableData.getCurrent();
197206
case STATISTICS_PANELS_KEYS.EFFICIENCY_PER_DETECTOR:
198207
return this._detectorEfficiencyTabModel;
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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+
import { ChartColors } from '../chartColors.js';
15+
import { barChartComponent } from '../../../components/common/chart/barChart/barChartComponent.js';
16+
import { displayEnvironmentStatusHistory } from '../../Environments/format/displayEnvironmentStatusHistory.js';
17+
18+
const VISIBLE_BIN_COUNT = 32;
19+
20+
/**
21+
* Bar chart displaying environment status history occurrences
22+
*
23+
* @param {{statusHistory: string, count: number}[]} environmentHistoryOccurrences the environment history occurrences
24+
* @return {Component} the chart component
25+
*/
26+
export const environmentHistoryOccurrencesBarChartComponent = (environmentHistoryOccurrences) => {
27+
const visibleBins = environmentHistoryOccurrences.slice(0, VISIBLE_BIN_COUNT);
28+
const excessBins = environmentHistoryOccurrences.slice(VISIBLE_BIN_COUNT);
29+
const excessCount = excessBins.reduce((sum, { count }) => sum + count, 0);
30+
31+
const points = visibleBins.map(({ statusHistory, count }) => ({
32+
x: displayEnvironmentStatusHistory(statusHistory),
33+
y: count,
34+
}));
35+
36+
if (excessCount > 0) {
37+
points.push({
38+
x: 'Other',
39+
y: excessCount,
40+
});
41+
}
42+
43+
return barChartComponent(points, {
44+
placeholder: 'No environment history on the given period',
45+
chartConfiguration: {
46+
axis: {
47+
x: {
48+
label: 'Environments',
49+
ticks: { overlapping: 'rotate' },
50+
},
51+
y: {
52+
label: 'Count',
53+
ticks: { format: (t) => Number.isInteger(t) ? t : null },
54+
min: 0,
55+
},
56+
},
57+
datasets: {
58+
bar: {
59+
fill: ChartColors.Blue.dark,
60+
stroke: ChartColors.Blue.light,
61+
},
62+
},
63+
},
64+
});
65+
};

0 commit comments

Comments
 (0)