Skip to content

Commit

Permalink
take transverse page into account in report
Browse files Browse the repository at this point in the history
  • Loading branch information
bellangerq committed Sep 13, 2024
1 parent b4e512b commit 7923958
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 59 deletions.
105 changes: 57 additions & 48 deletions confiture-rest-api/src/audits/audit.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,18 @@ import { UpdateAuditDto } from "./dto/update-audit.dto";
import { UpdateResultsDto } from "./dto/update-results.dto";
import { PatchAuditDto } from "./dto/patch-audit.dto";

const AUDIT_EDIT_INCLUDE: Prisma.AuditInclude = {
const AUDIT_EDIT_INCLUDE = {
recipients: true,
environments: true,
transverseElementsPage: true,
pages: true,
sourceAudit: {
select: {
procedureName: true
}
},
notesFiles: true
};
} as const;

@Injectable()
export class AuditService {
Expand Down Expand Up @@ -768,14 +769,10 @@ export class AuditService {
async getAuditReportData(
consultUniqueId: string
): Promise<AuditReportDto | undefined> {
const audit = (await this.prisma.audit.findUnique({
const audit = await this.prisma.audit.findUnique({
where: { consultUniqueId },
include: AUDIT_EDIT_INCLUDE
})) as Audit & {
environments: TestEnvironment[];
pages: AuditedPage[];
notesFiles: AuditFile[];
};
});

if (!audit) {
return;
Expand All @@ -784,7 +781,16 @@ export class AuditService {
const results = await this.prisma.criterionResult.findMany({
where: {
page: {
auditUniqueId: audit.editUniqueId
OR: [
{
auditUniqueId: audit.editUniqueId
},
{
auditTransverse: {
editUniqueId: audit.editUniqueId
}
}
]
},
criterium: {
in: CRITERIA_BY_AUDIT_TYPE[audit.auditType].map((c) => c.criterium)
Expand Down Expand Up @@ -896,7 +902,7 @@ export class AuditService {
browser: e.browser
})),
referencial: "RGAA Version 4.1",
samples: audit.pages
samples: [audit.transverseElementsPage, ...audit.pages]
.map((p, i) => ({
name: p.name,
order: p.order,
Expand All @@ -909,53 +915,56 @@ export class AuditService {
technologies: audit.technologies
},

pageDistributions: audit.pages.map((p) => ({
name: p.name,
compliant: {
raw: results.filter(
(r) =>
r.pageId === p.id && r.status === CriterionResultStatus.COMPLIANT
).length,
percentage:
(results.filter(
pageDistributions: [audit.transverseElementsPage, ...audit.pages].map(
(p) => ({
name: p.name,
compliant: {
raw: results.filter(
(r) =>
r.pageId === p.id &&
r.status === CriterionResultStatus.COMPLIANT
).length /
totalCriteriaCount) *
100
},
notApplicable: {
raw: results.filter(
(r) =>
r.pageId === p.id &&
r.status === CriterionResultStatus.NOT_APPLICABLE
).length,
percentage:
(results.filter(
).length,
percentage:
(results.filter(
(r) =>
r.pageId === p.id &&
r.status === CriterionResultStatus.COMPLIANT
).length /
totalCriteriaCount) *
100
},
notApplicable: {
raw: results.filter(
(r) =>
r.pageId === p.id &&
r.status === CriterionResultStatus.NOT_APPLICABLE
).length /
totalCriteriaCount) *
100
},
notCompliant: {
raw: results.filter(
(r) =>
r.pageId === p.id &&
r.status === CriterionResultStatus.NOT_COMPLIANT
).length,
percentage:
(results.filter(
).length,
percentage:
(results.filter(
(r) =>
r.pageId === p.id &&
r.status === CriterionResultStatus.NOT_APPLICABLE
).length /
totalCriteriaCount) *
100
},
notCompliant: {
raw: results.filter(
(r) =>
r.pageId === p.id &&
r.status === CriterionResultStatus.NOT_COMPLIANT
).length /
totalCriteriaCount) *
100
}
})),
).length,
percentage:
(results.filter(
(r) =>
r.pageId === p.id &&
r.status === CriterionResultStatus.NOT_COMPLIANT
).length /
totalCriteriaCount) *
100
}
})
),

resultDistribution: {
compliant: {
Expand Down
2 changes: 1 addition & 1 deletion confiture-web-app/src/components/report/ReportCriteria.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const hasFilters = computed(() => {
>
</li>
<li
v-for="page in pagesData"
v-for="page in pagesData.slice(1)"
:key="page.name"
class="fr-sidemenu__item"
:class="{
Expand Down
12 changes: 6 additions & 6 deletions confiture-web-app/src/components/report/ReportErrors.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,7 @@ const transverseErrors = computed(() => {
});
const pagesErrors = computed(() => {
return getReportErrors(
report,
quickWinFilter.value,
userImpactFilters.value
).slice(1);
return getReportErrors(report, quickWinFilter.value, userImpactFilters.value);
});
const errorsCount = computed(() => {
Expand Down Expand Up @@ -218,7 +214,11 @@ function resetFilters() {
</template>

<template #pages-data>
<section v-for="page in pagesErrors" :key="page.id" class="fr-mb-8w">
<section
v-for="page in pagesErrors.slice(1)"
:key="page.id"
class="fr-mb-8w"
>
<h2 :id="`${page.id}`" class="fr-h3 fr-mb-2w page-title">
{{ page.name }}
</h2>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const transverseImprovements = computed(() => {
});
const pagesImprovements = computed(() => {
return getReportImprovements(report).slice(1);
return getReportImprovements(report);
});
const improvementsCount = computed(() => {
Expand Down Expand Up @@ -61,7 +61,7 @@ const improvementsCount = computed(() => {

<template #pages-data>
<section
v-for="page in pagesImprovements"
v-for="page in pagesImprovements.slice(1)"
:key="page.id"
class="fr-mb-8w"
>
Expand Down
4 changes: 2 additions & 2 deletions confiture-web-app/src/components/report/ReportResults.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const pageDistributionTableData = {
data: [
["Pages", "Critères conformes", "Critères non conformes"],
...(report.data
? report.data.pageDistributions.map((p) => {
? report.data.pageDistributions.slice(1).map((p) => {
return [
p.name,
Math.round(p.compliant.raw),
Expand Down Expand Up @@ -212,7 +212,7 @@ const transverseNotCompliantCount = computed(() => {
concernent des éléments transverses à toutes les pages de
l’échantillon.
</p>
<!-- TODO: make this link work -->
<!-- FIXME: make this link work -->
<RouterLink
:to="{
name: 'report',
Expand Down

0 comments on commit 7923958

Please sign in to comment.