Skip to content

Commit

Permalink
res public
Browse files Browse the repository at this point in the history
  • Loading branch information
xsalonx committed Apr 30, 2024
1 parent 0492542 commit 34bd417
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 128 deletions.
13 changes: 0 additions & 13 deletions lib/public/views/QcFlags/ActiveColumns/qcFlagsActiveColumns.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@
* or submit itself to any jurisdiction.
*/

import { iconWarning } from '/js/src/index.js';
import { tooltip } from '../../../components/common/popover/tooltip.js';
import { formatTimestamp } from '../../../utilities/formatting/formatTimestamp.js';
import { qcFlagTypeColoredBadge } from '../common/qcFlagTypeColoredBadge.js';
import { formatFloat } from '../../../utilities/formatting/formatFloat.js';

/**
* Active columns configuration for QC flags table
Expand Down Expand Up @@ -43,16 +40,6 @@ export const qcFlagsActiveColumns = {
: 'Whole run coverage',
},

effectivePart: {
name: 'eff. part (%)',
visible: true,
format: (effectivePart) => effectivePart > 0
? formatFloat(
100 * effectivePart,
{ precision: 1 },
)
: tooltip(iconWarning(), 'Flag is discarded'),
},
comment: {
name: 'Comment',
visible: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,44 +12,6 @@
*/
import { h } from '/js/src/index.js';
import { frontLink } from '../../../components/common/navigation/frontLink.js';
import { formatFloat } from '../../../utilities/formatting/formatFloat.js';

/**
* Render QC summary for given run and detector
* @param {number} runNumber run numbrt
* @param {number} dplDetectorId id of the detector
* @param {QcSummary} qcSummary QC summary
* @return {Component} component
*/
const runDetectorAsyncQualityDisplay = (runNumber, dplDetectorId, qcSummary) => {
if (!qcSummary?.[runNumber]?.[dplDetectorId]) {
return h('.btn.white.bg-primary', 'QC');
}

const {
badEffectiveRunCoverage = null,
explicitlyNotBadEffectiveRunCoverage = null,
missingVerificationsCount = 0,
} = qcSummary[runNumber][dplDetectorId];

const notBadPercentageFormat = h('', [
formatFloat((1 - badEffectiveRunCoverage) * 100, { precision: 0 }),
missingVerificationsCount ? h('sub', `!${missingVerificationsCount}`) : null,
]);
if (!badEffectiveRunCoverage) {
if (explicitlyNotBadEffectiveRunCoverage === 1) {
return h('.bg-success.black.btn', notBadPercentageFormat);
} else {
return h('.bg-gray.black.btn', notBadPercentageFormat);
}
} else {
if (badEffectiveRunCoverage === 1) {
return h('.bg-danger.black.btn', notBadPercentageFormat);
} else {
return h('.bg-warning.black.btn', notBadPercentageFormat);
}
}
};

/**
* Factory for detectors related active columns configuration
Expand All @@ -60,7 +22,7 @@ const runDetectorAsyncQualityDisplay = (runNumber, dplDetectorId, qcSummary) =>
* @param {number} [options.simulationPassId] if provided a cell become link to QC flag page for given simulation pass
* @return {object} active columns configuration
*/
export const createRunDetectorsAsyncQcActiveColumns = (dplDetectors, { profiles, dataPassId, simulationPassId, qcSummary } = {}) =>
export const createRunDetectorsAsyncQcActiveColumns = (dplDetectors, { profiles, dataPassId, simulationPassId } = {}) =>
Object.fromEntries(dplDetectors?.map(({ name: detectorName, id: dplDetectorId }) => [
detectorName, {
name: detectorName.toUpperCase(),
Expand All @@ -74,8 +36,7 @@ export const createRunDetectorsAsyncQcActiveColumns = (dplDetectors, { profiles,
if (!detectorWasActiveDuringRun) {
return null;
}

const detectorQualityDisplay = runDetectorAsyncQualityDisplay(run.runNumber, dplDetectorId, qcSummary);
const detectorQualityDisplay = h('.btn.white.bg-primary', 'QC');

if (dataPassId) {
return frontLink(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { RunsOverviewModel } from '../Overview/RunsOverviewModel.js';
import { ObservableData } from '../../../utilities/ObservableData.js';
import { getRemoteDataSlice } from '../../../utilities/fetch/getRemoteDataSlice.js';
import { dplDetectorsProvider } from '../../../services/detectors/dplDetectorsProvider.js';
import { getRemoteData } from '../../../utilities/fetch/getRemoteData.js';

/**
* Runs Per Data Pass overview model
Expand All @@ -32,8 +31,6 @@ export class RunsPerDataPassOverviewModel extends RunsOverviewModel {
this._detectors$.bubbleTo(this);
this._dataPass = new ObservableData(RemoteData.notAsked());
this._dataPass.bubbleTo(this);
this._qcSummary$ = new ObservableData(RemoteData.NotAsked());
this._qcSummary$.bubbleTo(this);
}

/**
Expand All @@ -50,20 +47,6 @@ export class RunsPerDataPassOverviewModel extends RunsOverviewModel {
}
}

/**
* Fetch QC summaries for given data pass
* @return {Promise<void>} promise
*/
async _fetchQcSummary() {
this._qcSummary$.setCurrent(RemoteData.loading());
try {
const { data: qcSummary } = await getRemoteData(buildUrl('/api/qcFlags/perDataPass/summary', { dataPassId: this._dataPassId }));
this._qcSummary$.setCurrent(RemoteData.success(qcSummary));
} catch (error) {
this._qcSummary$.setCurrent(RemoteData.failure(error));
}
}

// eslint-disable-next-line valid-jsdoc
/**
* @inheritdoc
Expand All @@ -73,7 +56,6 @@ export class RunsPerDataPassOverviewModel extends RunsOverviewModel {
return;
}
this._fetchDataPass();
this._fetchQcSummary();
super.load();
}

Expand Down Expand Up @@ -110,12 +92,4 @@ export class RunsPerDataPassOverviewModel extends RunsOverviewModel {
get detectors() {
return this._detectors$.getCurrent();
}

/**
* QC summary getter
* @return {RemoteData<QcSummary>} qcsummary
*/
get qcSummary() {
return this._qcSummary$.getCurrent();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,7 @@ export const RunsPerDataPassOverviewPage = ({ runs: { perDataPassOverviewModel }
PAGE_USED_HEIGHT,
));

const {
items: remoteRuns,
detectors: remoteDetectors,
dataPass: remoteDataPass,
qcSummary: remoteQcSummary,
} = perDataPassOverviewModel;
const { items: remoteRuns, detectors: remoteDetectors, dataPass: remoteDataPass } = perDataPassOverviewModel;

const activeColumns = {
...runsActiveColumns,
Expand All @@ -70,10 +65,6 @@ export const RunsPerDataPassOverviewPage = ({ runs: { perDataPassOverviewModel }
Success: (dataPass) => dataPass.id,
Other: () => null,
}),
qcSummary: remoteQcSummary.match({
Success: (qcSummary) => qcSummary,
Other: () => null,
}),
}),
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ export class RunsPerSimulationPassOverviewModel extends RunsOverviewModel {
this._detectors$.bubbleTo(this);
this._simulationPass$ = new ObservableData(RemoteData.notAsked());
this._simulationPass$.bubbleTo(this);
this._qcSummary$ = new ObservableData(RemoteData.NotAsked());
this._qcSummary$.bubbleTo(this);
}

/**
Expand All @@ -49,29 +47,11 @@ export class RunsPerSimulationPassOverviewModel extends RunsOverviewModel {
}
}

/**
* Fetch QC summaries for given data pass
* @return {Promise<void>} promise
*/
async _fetchQcSummary() {
this._qcSummary$.setCurrent(RemoteData.loading());
try {
const { data: qcSummary } = await getRemoteData(buildUrl(
'/api/qcFlags/perSimulationPass/summary',
{ simulationPassId: this._simulationPassId },
));
this._qcSummary$.setCurrent(RemoteData.success(qcSummary));
} catch (error) {
this._qcSummary$.setCurrent(RemoteData.failure(error));
}
}

// eslint-disable-next-line valid-jsdoc
/**
* @inheritdoc
*/
async load() {
this._fetchQcSummary();
this._fetchSimulationPass();
super.load();
}
Expand Down Expand Up @@ -113,12 +93,4 @@ export class RunsPerSimulationPassOverviewModel extends RunsOverviewModel {
get detectors() {
return this._detectors$.getCurrent();
}

/**
* QC summary getter
* @return {RemoteData<QcSummary>} qcsummary
*/
get qcSummary() {
return this._qcSummary$.getCurrent();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,7 @@ export const RunsPerSimulationPassOverviewPage = ({
PAGE_USED_HEIGHT,
));

const {
items: remoteRuns,
detectors: remoteDetectors,
simulationPass: remoteSimulationPass,
qcSummary: remoteQcSummary,
} = runsPerSimulationPassOverviewModel;
const { items: remoteRuns, detectors: remoteDetectors, simulationPass: remoteSimulationPass } = runsPerSimulationPassOverviewModel;

const activeColumns = {
...runsActiveColumns,
Expand All @@ -71,10 +66,6 @@ export const RunsPerSimulationPassOverviewPage = ({
Success: (simulationPass) => simulationPass.id,
Other: () => null,
}),
qcSummary: remoteQcSummary.match({
Success: (qcSummary) => qcSummary,
Other: () => null,
}),
}),
};

Expand Down

0 comments on commit 34bd417

Please sign in to comment.