Skip to content

Commit

Permalink
fix tests, preserve previous functionalties
Browse files Browse the repository at this point in the history
  • Loading branch information
xsalonx committed Dec 3, 2024
1 parent d6e7fcb commit 1658d1d
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 17 deletions.
2 changes: 1 addition & 1 deletion lib/database/repositories/QcFlagRepository.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class QcFlagRepository extends Repository {
mcReproducible: Boolean(mcReproducible),
flagsIds: flagsList ? [...new Set(flagsList.split(','))] : [],
verifiedFlagsIds: verifiedFlagsList ? [...new Set(verifiedFlagsList.split(','))] : [],
})).filter(({ bad }) => bad !== null);
}));
}

/**
Expand Down
42 changes: 31 additions & 11 deletions lib/server/services/qualityControlFlag/QcFlagService.js
Original file line number Diff line number Diff line change
Expand Up @@ -688,11 +688,18 @@ class QcFlagService {
distinctVerifiedFlagsIds: new Set([...distinctRunVerifiedFlagsIds, ...verifiedFlagsIds]),
};

this._mergeIntoSummaryUnit(runSummary, subSummary);
if (subSummary.bad !== null) {
this._mergeIntoSummaryUnit(runSummary, subSummary);
}
}

for (const [runNumber, { distinctFlagsIds, distinctVerifiedFlagsIds }] of Object.entries(flagsAndVerifications)) {
summary[runNumber][QC_SUMMARY_PROPERTIES.missingVerificationsCount] = distinctFlagsIds.size - distinctVerifiedFlagsIds.size;
if (!summary[runNumber][QC_SUMMARY_PROPERTIES.badEffectiveRunCoverage] &&
!summary[runNumber][QC_SUMMARY_PROPERTIES.explicitlyNotBadEffectiveRunCoverage]
) {
delete summary[runNumber];
}
}

return summary;
Expand All @@ -713,20 +720,33 @@ class QcFlagService {
mcReproducible,
} = partialSummaryUnit;

const { badEffectiveRunCoverage, explicitlyNotBadEffectiveRunCoverage } = summaryUnit;

if (bad) {
summaryUnit[QC_SUMMARY_PROPERTIES.badEffectiveRunCoverage] = effectiveRunCoverage;
summaryUnit[QC_SUMMARY_PROPERTIES.mcReproducible] =
mcReproducible || summaryUnit[QC_SUMMARY_PROPERTIES.mcReproducible];
} else {
summaryUnit[QC_SUMMARY_PROPERTIES.explicitlyNotBadEffectiveRunCoverage] = effectiveRunCoverage;
if (effectiveRunCoverage !== null && badEffectiveRunCoverage !== null) {
summaryUnit.badEffectiveRunCoverage =
(badEffectiveRunCoverage ?? 0) + effectiveRunCoverage;
} else {
summaryUnit.badEffectiveRunCoverage = null;
}

summaryUnit[QC_SUMMARY_PROPERTIES.mcReproducible] =
mcReproducible || summaryUnit[QC_SUMMARY_PROPERTIES.mcReproducible];
mcReproducible || summaryUnit.mcReproducible;
} else if (bad !== null) {
if (effectiveRunCoverage !== null && explicitlyNotBadEffectiveRunCoverage !== null) {
summaryUnit.explicitlyNotBadEffectiveRunCoverage =
(explicitlyNotBadEffectiveRunCoverage ?? 0) + effectiveRunCoverage;
} else {
summaryUnit.explicitlyNotBadEffectiveRunCoverage = null;
}
summaryUnit.mcReproducible =
mcReproducible || summaryUnit.mcReproducible;
}
if (summaryUnit[QC_SUMMARY_PROPERTIES.badEffectiveRunCoverage] === undefined) {
summaryUnit[QC_SUMMARY_PROPERTIES.badEffectiveRunCoverage] = 0;
if (summaryUnit.badEffectiveRunCoverage === undefined) {
summaryUnit.badEffectiveRunCoverage = 0;
}
if (summaryUnit[QC_SUMMARY_PROPERTIES.explicitlyNotBadEffectiveRunCoverage] === undefined) {
summaryUnit[QC_SUMMARY_PROPERTIES.explicitlyNotBadEffectiveRunCoverage] = 0;
if (summaryUnit.explicitlyNotBadEffectiveRunCoverage === undefined) {
summaryUnit.explicitlyNotBadEffectiveRunCoverage = 0;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1447,19 +1447,20 @@ module.exports = () => {
const timeTrgEnd = t('22:00:00');

const gaqSubSummaries = [
{ from: t('06:00:00'), to: t('10:00:00'), bad: true, mcReproducible: false },
{ from: t('06:00:00'), to: t('10:00:00'), bad: null, mcReproducible: false },
{ from: t('10:00:00'), to: t('12:00:00'), bad: true, mcReproducible: false },
{ from: t('12:00:00'), to: t('13:00:00'), bad: true, mcReproducible: true },
{ from: t('13:00:00'), to: t('14:00:00'), bad: true, mcReproducible: true },
{ from: t('13:00:00'), to: t('14:00:00'), bad: null, mcReproducible: true },
{ from: t('14:00:00'), to: t('16:00:00'), bad: true, mcReproducible: false },
{ from: t('18:00:00'), to: t('20:00:00'), bad: false, mcReproducible: false },
{ from: t('20:00:00'), to: t('22:00:00'), bad: false, mcReproducible: false },
{ from: t('16:00:00'), to: t('18:00:00'), bad: null, mcReproducible: false },
{ from: t('18:00:00'), to: t('20:00:00'), bad: null, mcReproducible: false },
{ from: t('20:00:00'), to: t('22:00:00'), bad: null, mcReproducible: false },
];

const expectedGaqSummary = gaqSubSummaries.reduce((acc, { from, to, bad, mcReproducible }) => {
if (bad) {
acc.badEffectiveRunCoverage += to - from;
} else {
} else if (bad !== null) {
acc.explicitlyNotBadEffectiveRunCoverage += to - from;
}
acc.mcReproducible = acc.mcReproducible || mcReproducible;
Expand Down

0 comments on commit 1658d1d

Please sign in to comment.