Skip to content

Commit

Permalink
exclude transverse results from audit progression
Browse files Browse the repository at this point in the history
  • Loading branch information
bellangerq committed Sep 18, 2024
1 parent ce629b0 commit 58f3632
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions confiture-web-app/src/store/results.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,17 @@ export const useResultsStore = defineStore("results", {
},

/**
* @returns True when every criterium in the audit have been tested (status is different from NOT_TESTED)
* @returns True when every criterium (transverse excluded) in the audit have been tested (status is different from NOT_TESTED)
*/
everyCriteriumAreTested(): boolean {
const auditStore = useAuditStore();
const transversePageId =
auditStore.currentAudit?.transverseElementsPage.id;

return (
!this.allResults?.some(
(r) => r.status === CriteriumResultStatus.NOT_TESTED
) ?? false
!this.allResults
?.filter((r) => r.pageId !== transversePageId)
.some((r) => r.status === CriteriumResultStatus.NOT_TESTED) ?? false
);
},

Expand All @@ -144,16 +148,23 @@ export const useResultsStore = defineStore("results", {

/**
* Ratio of tested criteria over total number of criteria.
* Transverse criteria are excluded.
*
* `0.5` means half of the audit criteria have been tested.
*/
auditProgress(): number {
if (!this.data) {
return 0;
}

const auditStore = useAuditStore();
const transversePageId =
auditStore.currentAudit?.transverseElementsPage.id;

const r = Object.values(this.data)
.flatMap(Object.values)
.flatMap(Object.values) as CriteriumResult[];
.flatMap(Object.values)
.filter((cr) => cr.pageId !== transversePageId) as CriteriumResult[];

const total = r.length;

Expand Down

0 comments on commit 58f3632

Please sign in to comment.