Skip to content

Commit

Permalink
Merge branch 'main' into xsalonx/MICS/O2B-1099/mode-reset-filter-btn-…
Browse files Browse the repository at this point in the history
…on-top
  • Loading branch information
xsalonx committed Apr 30, 2024
2 parents 950ef22 + 4972474 commit a7c28a6
Show file tree
Hide file tree
Showing 21 changed files with 223 additions and 52 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [0.86.0](https://github.com/AliceO2Group/Bookkeeping/releases/tag/%40aliceo2%2Fbookkeeping%400.86.0)
* Notable changes for users:
* Placed RCT entry point directly in navigation bar
* Changed QC flag delete button access to admins only
* Added runs counts for simulation pass overview
* Added data passes counts for simulation pass overview
* ALICE efficiency computation now uses mean weighted by stable beam duration
* Removed missing trigger start/stop warning if trigger is OFF
* Notable change for developers:
* Run optional properties are now optional in proto file

## [0.85.0](https://github.com/AliceO2Group/Bookkeeping/releases/tag/%40aliceo2%2Fbookkeeping%400.85.0)
* Notable changes for users:
* Added possibility to filter out runs that contains any of the given tags
Expand Down
3 changes: 3 additions & 0 deletions lib/database/adapters/LhcFillStatisticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class LhcFillStatisticsAdapter {
toEntity(databaseObject) {
const {
fillNumber,
stableBeamsDuration,
runsCoverage,
efficiency,
timeLossAtStart,
Expand All @@ -38,6 +39,8 @@ class LhcFillStatisticsAdapter {
return {
fillNumber,
// Convert to ms
stableBeamsDuration: stableBeamsDuration * 1000,
// Convert to ms
runsCoverage: runsCoverage * 1000,
efficiency: parseFloat(efficiency),
// Convert to ms
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
/**
* @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.
*/

'use strict';

const ROLLBACK_FILL_STATISTICS_TO_PREVIOUS = `
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/**
* @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.
*/

'use strict';

const UPDATE_FILL_STATISTICS_VIEW = `
CREATE OR REPLACE VIEW fill_statistics AS
SELECT lf.fill_number,
-- Use max to comply with gruop by, but all the values are the same in the group
COALESCE(MAX(sbr.sb_duration), 0) stable_beams_duration,
SUM(sbr.sb_run_duration) runs_coverage,
SUM(COALESCE(sbr.sb_run_duration / sbr.sb_duration, 0)) efficiency,
COALESCE(
TO_SECONDS(MIN(sbr.sb_run_start)) - TO_SECONDS(MAX(sbr.sb_start)),
0
) time_loss_at_start,
COALESCE(
(TO_SECONDS(MIN(sbr.sb_run_start)) - TO_SECONDS(MAX(sbr.sb_start))) / MAX(sbr.sb_duration),
0
) efficiency_loss_at_start,
COALESCE(TO_SECONDS(MIN(sbr.sb_end)) - TO_SECONDS(MAX(sbr.sb_run_end)), 0) time_loss_at_end,
COALESCE(
(TO_SECONDS(MIN(sbr.sb_end)) - TO_SECONDS(MAX(sbr.sb_run_end))) / MAX(sbr.sb_duration),
0
) efficiency_loss_at_end,
COALESCE(AVG(sbr.sb_run_duration), 0) mean_run_duration,
COALESCE(SUM(r.ctf_file_size), 0) total_ctf_file_size,
COALESCE(SUM(r.tf_file_size), 0) total_tf_file_size
FROM lhc_fills lf
LEFT JOIN runs r ON r.fill_number = lf.fill_number AND r.definition = 'PHYSICS' AND r.run_quality = 'good'
LEFT JOIN stable_beam_runs sbr ON sbr.run_number = r.run_number
WHERE lf.stable_beams_start IS NOT NULL
GROUP BY lf.fill_number;
`;

const ROLLBACK_FILL_STATISTICS_TO_PREVIOUS = `
CREATE OR REPLACE VIEW fill_statistics AS
SELECT lf.fill_number,
SUM(sbr.sb_run_duration) runs_coverage,
SUM(COALESCE(sbr.sb_run_duration / sbr.sb_duration, 0)) efficiency,
COALESCE(
TO_SECONDS(MIN(sbr.sb_run_start)) - TO_SECONDS(MAX(sbr.sb_start)),
0
) time_loss_at_start,
COALESCE(
(TO_SECONDS(MIN(sbr.sb_run_start)) - TO_SECONDS(MAX(sbr.sb_start))) / MAX(sbr.sb_duration),
0
) efficiency_loss_at_start,
COALESCE(TO_SECONDS(MIN(sbr.sb_end)) - TO_SECONDS(MAX(sbr.sb_run_end)), 0) time_loss_at_end,
COALESCE(
(TO_SECONDS(MIN(sbr.sb_end)) - TO_SECONDS(MAX(sbr.sb_run_end))) / MAX(sbr.sb_duration),
0
) efficiency_loss_at_end,
COALESCE(AVG(sbr.sb_run_duration), 0) mean_run_duration,
COALESCE(SUM(r.ctf_file_size), 0) total_ctf_file_size,
COALESCE(SUM(r.tf_file_size), 0) total_tf_file_size
FROM lhc_fills lf
LEFT JOIN runs r ON r.fill_number = lf.fill_number AND r.definition = 'PHYSICS' AND r.run_quality = 'good'
LEFT JOIN stable_beam_runs sbr ON sbr.run_number = r.run_number
WHERE lf.stable_beams_start IS NOT NULL
GROUP BY lf.fill_number;
`;

/** @type {import('sequelize-cli').Migration} */
module.exports = {
up: async (queryInterface) => queryInterface.sequelize.transaction(async (transaction) => {
await queryInterface.sequelize.query(UPDATE_FILL_STATISTICS_VIEW, { transaction });
}),

down: async (queryInterface) => queryInterface.sequelize.transaction(async (transaction) => {
await queryInterface.sequelize.query(ROLLBACK_FILL_STATISTICS_TO_PREVIOUS, { transaction });
}),
};
4 changes: 4 additions & 0 deletions lib/database/models/lhcFillStatistics.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ module.exports = (sequelize) => {
type: Sequelize.NUMBER,
primaryKey: true,
},
stableBeamsDuration: {
allowNull: false,
type: Sequelize.NUMBER,
},
runsCoverage: {
allowNull: false,
type: Sequelize.NUMBER,
Expand Down
1 change: 1 addition & 0 deletions lib/database/models/typedefs/SequelizeLhcFillStatistics.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* @typedef SequelizeLhcFillStatistics
*
* @property {number} fillNumber the fill number to which the statistics applies to
* @property {number} stableBeamsDuration the duration of the fill stable beams
* @property {number} runsCoverage total duration covered by at least one run (in seconds)
* @property {string} efficiency efficiency of the fill
* @property {number} timeLossAtStart duration between the start of the fill and the start of the first run (in seconds)
Expand Down
3 changes: 1 addition & 2 deletions lib/database/seeders/20200713103855-runs.js
Original file line number Diff line number Diff line change
Expand Up @@ -2667,8 +2667,6 @@ module.exports = {
run_number: 107,
time_o2_start: '2019-08-08 13:00:00',
time_o2_end: '2019-08-09 14:00:00',
time_trg_start: '2019-08-08 13:00:00',
time_trg_end: '2019-08-09 14:00:00',
run_type_id: 12,
run_quality: 'good',
n_detectors: 15,
Expand All @@ -2682,6 +2680,7 @@ module.exports = {
fill_number: 1,
epn_topology: 'a quite long topology, which will for sure require a balloon to be displayed properly',
concatenated_detectors: 'ACO, CPV, CTP, EMC, FIT, HMP, ITS, MCH, MFT, MID, PHS, TOF, TPC, TRD, ZDC',
trigger_value: 'OFF',
lhc_period_id: 2,
lhc_beam_mode: 'UNSTABLE BEAMS',
odc_topology_full_name: 'hash',
Expand Down
1 change: 1 addition & 0 deletions lib/domain/entities/statistics/LhcFillStatistics.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* @typedef LhcFillStatistics
*
* @property {number} fillNumber the fill number to which the statistics applies to
* @property {number} stableBeamsDuration the total stable beam duration of the fill
* @property {number} runsCoverage total duration covered by at least one run (in ms)
* @property {number} efficiency efficiency of the fill
* @property {number} timeLossAtStart duration between the start of the fill and the start of the first run (in ms)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { checkboxFilter } from '../common/filters/checkboxFilter.js';

const TRIGGER_VALUES = ['OFF', 'LTU', 'CTP'];
import { TRIGGER_VALUES } from '../../../domain/enums/TriggerValue.js';

/**
* Returns a panel to be used by user to filter runs by trigger value
* @param {RunsOverviewModel} runModel The global model object
* @return {vnode} Multiple checkboxes for a user to select the values to be filtered.
*/
const triggerValue = (runModel) => checkboxFilter(
export const triggerValueFilter = (runModel) => checkboxFilter(
'triggerValue',
TRIGGER_VALUES,
(value) => runModel.triggerValuesFilters.has(value),
Expand All @@ -20,5 +19,3 @@ const triggerValue = (runModel) => checkboxFilter(
runModel.triggerValuesFilters = Array.from(runModel.triggerValuesFilters);
},
);

export default triggerValue;
20 changes: 20 additions & 0 deletions lib/public/domain/enums/TriggerValue.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* @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.
*/

export const TriggerValue = Object.freeze({
Off: 'OFF',
CTP: 'CTP',
LTU: 'LTU',
});

export const TRIGGER_VALUES = Object.values(TriggerValue);
2 changes: 1 addition & 1 deletion lib/public/views/Runs/ActiveColumns/runsActiveColumns.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import { displayRunDuration } from '../format/displayRunDuration.js';
import fillNumbersFilter from '../../../components/Filters/RunsFilter/fillNumbers.js';
import { frontLink } from '../../../components/common/navigation/frontLink.js';
import nEpnsFilter from '../../../components/Filters/RunsFilter/nEpns.js';
import triggerValueFilter from '../../../components/Filters/RunsFilter/triggerValue.js';
import { triggerValueFilter } from '../../../components/Filters/RunsFilter/triggerValueFilter.js';
import lhcPeriodsFilter from '../../../components/Filters/RunsFilter/lhcPeriod.js';
import { formatRunType } from '../../../utilities/formatting/formatRunType.js';
import definitionFilter from '../../../components/Filters/RunsFilter/definitionFilter.js';
Expand Down
23 changes: 14 additions & 9 deletions lib/public/views/Runs/format/displayRunDuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ import { h, iconWarning } from '/js/src/index.js';
import { MAX_RUN_DURATION } from '../../../services/run/constants.mjs';
import { formatRunDuration } from '../../../utilities/formatting/formatRunDuration.mjs';
import { tooltip } from '../../../components/common/popover/tooltip.js';
import { TriggerValue } from '../../../domain/enums/TriggerValue.js';

/**
* Format the duration of a given run
*
* @param {Object} run for which duration must be displayed
*
* @param {Run} run for which duration must be displayed
* @return {string|vnode} the formatted duration
*/
export const displayRunDuration = (run) => {
const { runDuration, timeTrgStart, timeTrgEnd, timeO2Start, timeO2End } = run;
const { runDuration, timeTrgStart, timeTrgEnd, timeO2Start, timeO2End, triggerValue } = run;

const formattedRunDuration = formatRunDuration(run);

Expand All @@ -35,15 +35,18 @@ export const displayRunDuration = (run) => {
const missingTimeTrgStart = timeTrgStart === null || timeTrgStart === undefined;
const missingTimeTrgEnd = timeTrgEnd === null || timeTrgEnd === undefined;

// Run has ended
if (timeTrgEnd || timeO2End) {
let warningPopover = null;

if (missingTimeTrgStart && missingTimeTrgEnd) {
warningPopover = 'Duration based on o2 start AND stop because of missing trigger information';
} else if (missingTimeTrgStart) {
warningPopover = 'Duration based on o2 start because of missing trigger start information';
} else if (missingTimeTrgEnd) {
warningPopover = 'Duration based on o2 stop because of missing trigger stop information';
if (triggerValue !== TriggerValue.Off) {
if (missingTimeTrgStart && missingTimeTrgEnd) {
warningPopover = 'Duration based on o2 start AND stop because of missing trigger information';
} else if (missingTimeTrgStart) {
warningPopover = 'Duration based on o2 start because of missing trigger start information';
} else if (missingTimeTrgEnd) {
warningPopover = 'Duration based on o2 stop because of missing trigger stop information';
}
}

return h('.flex-row', h(
Expand All @@ -52,6 +55,8 @@ export const displayRunDuration = (run) => {
));
}

// Run is either running or lost

const timeStart = missingTimeTrgStart ? timeO2Start : timeTrgStart;

let classes = 'success';
Expand Down
28 changes: 18 additions & 10 deletions lib/public/views/Runs/format/formatRunEnd.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { formatTimestamp } from '../../../utilities/formatting/formatTimestamp.j
import { iconWarning, h } from '/js/src/index.js';
import { getLocaleDateAndTime } from '../../../utilities/dateUtils.js';
import { tooltip } from '../../../components/common/popover/tooltip.js';
import { TriggerValue } from '../../../domain/enums/TriggerValue.js';

const MISSING_TRIGGER_STOP_WARNING = 'O2 stop is displayed because trigger stop is missing';

Expand All @@ -26,20 +27,27 @@ const MISSING_TRIGGER_STOP_WARNING = 'O2 stop is displayed because trigger stop
* @return {Component} the formatted end date
*/
export const formatRunEnd = (run, inline) => {
if (run.timeTrgEnd) {
return formatTimestamp(run.timeTrgEnd, inline);
const { timeTrgEnd, timeO2End, triggerValue } = run;

if (timeTrgEnd || triggerValue === TriggerValue.Off) {
return formatTimestamp(timeTrgEnd || timeO2End, inline);
}
if (run.timeO2End) {
const { date, time } = getLocaleDateAndTime(run.timeO2End);
const content = inline
? h('span', [

if (timeO2End) {
if (inline) {
return h('span', [
h('.flex-row.items-center.g2', [
formatTimestamp(run.timeO2End, inline),
formatTimestamp(timeO2End, inline),
tooltip(iconWarning(), MISSING_TRIGGER_STOP_WARNING),
]),
])
: h('', h('', date), h('.flex-row.g2.items-center', [h('', time), tooltip(iconWarning(), MISSING_TRIGGER_STOP_WARNING)]));
return content;
]);
} else {
const { date, time } = getLocaleDateAndTime(timeO2End);
return h('', [
h('', date),
h('.flex-row.g2.items-center', [h('', time), tooltip(iconWarning(), MISSING_TRIGGER_STOP_WARNING)]),
]);
}
}
return '-';
};
32 changes: 20 additions & 12 deletions lib/public/views/Runs/format/formatRunStart.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ import { formatTimestamp } from '../../../utilities/formatting/formatTimestamp.j
import { iconWarning, h } from '/js/src/index.js';
import { getLocaleDateAndTime } from '../../../utilities/dateUtils.js';
import { tooltip } from '../../../components/common/popover/tooltip.js';
import { TriggerValue } from '../../../domain/enums/TriggerValue.js';

const MISSING_TRIGGER_STOP_WARNING = 'O2 stop is displayed because trigger stop is missing';
const MISSING_TRIGGER_START_WARNING = 'O2 start is displayed because trigger stop is missing';

/**
* Format a given run's start date
Expand All @@ -26,20 +27,27 @@ const MISSING_TRIGGER_STOP_WARNING = 'O2 stop is displayed because trigger stop
* @return {Component} the formatted start date
*/
export const formatRunStart = (run, inline) => {
if (run.timeTrgStart) {
return formatTimestamp(run.timeTrgStart, inline);
const { timeO2Start, timeTrgStart, triggerValue } = run;

if (timeTrgStart || triggerValue === TriggerValue.Off) {
return formatTimestamp(timeTrgStart || timeO2Start, inline);
}
if (run.timeO2Start) {
const { date, time } = getLocaleDateAndTime(run.timeO2Start);
const content = inline
? h('span', [

if (timeO2Start) {
if (inline) {
return h('span', [
h('.flex-row.items-center.g2', [
formatTimestamp(run.timeO2Start, inline),
tooltip(iconWarning(), MISSING_TRIGGER_STOP_WARNING),
formatTimestamp(timeO2Start, inline),
tooltip(iconWarning(), MISSING_TRIGGER_START_WARNING),
]),
])
: h('', h('', date), h('.flex-row.g2.items-center', [h('', time), tooltip(iconWarning(), MISSING_TRIGGER_STOP_WARNING)]));
return content;
]);
} else {
const { date, time } = getLocaleDateAndTime(timeO2Start);
return h('', [
h('', date),
h('.flex-row.g2.items-center', [h('', time), tooltip(iconWarning(), MISSING_TRIGGER_START_WARNING)]),
]);
}
}
return '-';
};
Loading

0 comments on commit a7c28a6

Please sign in to comment.