Skip to content

Commit

Permalink
fix audit stats computing
Browse files Browse the repository at this point in the history
  • Loading branch information
bellangerq committed Oct 2, 2024
1 parent 7c1f5df commit 36fd970
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 19 deletions.
24 changes: 15 additions & 9 deletions confiture-rest-api/src/audits/audit.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -820,17 +820,23 @@ export class AuditService {
);

const notApplicableCriteria = Object.values(groupedCriteria).filter(
(criteria) =>
criteria.every((c) => c.status === CriterionResultStatus.NOT_APPLICABLE)
(criteria) => {
return criteria
.filter((c) => c.pageId !== audit.transverseElementsPageId)
.every((c) => c.status === CriterionResultStatus.NOT_APPLICABLE);
}
);

const compliantCriteria = applicableCriteria.filter((criteria) =>
criteria.every(
(c) =>
c.status === CriterionResultStatus.COMPLIANT ||
c.status === CriterionResultStatus.NOT_APPLICABLE
)
);
const compliantCriteria = applicableCriteria.filter((criteria) => {
// Exclude criteria from transverse elements page.
return criteria
.filter((c) => c.pageId !== audit.transverseElementsPageId)
.every(
(c) =>
c.status === CriterionResultStatus.COMPLIANT ||
c.status === CriterionResultStatus.NOT_APPLICABLE
);
});

const notCompliantCriteria = applicableCriteria.filter((criteria) =>
criteria.some((c) => c.status === CriterionResultStatus.NOT_COMPLIANT)
Expand Down
30 changes: 20 additions & 10 deletions confiture-web-app/src/composables/useAuditStats.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { computed } from "vue";

import { useResultsStore } from "../store";
import { useAuditStore, useResultsStore } from "../store";
import {
CriterionResultUserImpact,
CriteriumResult,
CriteriumResultStatus
} from "../types";

export function useAuditStats() {
const auditStore = useAuditStore();
const store = useResultsStore();

const groupedCriteria = computed(() => {
Expand All @@ -33,15 +34,20 @@ export function useAuditStats() {
const notApplicableCriteriaCount = computed(() => {
return Object.values(groupedCriteria.value).filter((criteria) => {
return criteria
.slice(1)
.filter(
(c) => c.pageId !== auditStore.currentAudit?.transverseElementsPage.id
)
.every((c) => c.status === CriteriumResultStatus.NOT_APPLICABLE);
}).length;
});

const compliantCriteriaCount = computed(() => {
return applicableCriteria.value.filter((criteria) => {
// Exclude criteria from transverse elements page.
return criteria
.slice(1)
.filter(
(c) => c.pageId !== auditStore.currentAudit?.transverseElementsPage.id
)
.every(
(c) =>
c.status === CriteriumResultStatus.COMPLIANT ||
Expand Down Expand Up @@ -72,13 +78,17 @@ export function useAuditStats() {
criteria.some((c) => c.status !== CriteriumResultStatus.NOT_APPLICABLE)
);

const compliantCriteria = applicableCriteria.filter((criteria) =>
criteria.every(
(c) =>
c.status === CriteriumResultStatus.COMPLIANT ||
c.status === CriteriumResultStatus.NOT_APPLICABLE
)
);
const compliantCriteria = applicableCriteria.filter((criteria) => {
return criteria
.filter(
(c) => c.pageId !== auditStore.currentAudit?.transverseElementsPage.id
)
.every(
(c) =>
c.status === CriteriumResultStatus.COMPLIANT ||
c.status === CriteriumResultStatus.NOT_APPLICABLE
);
});

return (
Math.round(
Expand Down

0 comments on commit 36fd970

Please sign in to comment.