Skip to content

Commit

Permalink
Merge branch 'main' into 771-bug-mise-à-jour-de-la-page-paramètre-dun…
Browse files Browse the repository at this point in the history
…-audit
  • Loading branch information
bellangerq authored Nov 15, 2024
2 parents 12d2ff8 + 068379e commit 56158d9
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 95 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Tous les changements notables de Ara sont documentés ici avec leur date, leur c
### Corrections 🐛

- Corrige la "fausse" mise à jour des paramètres de l’audit quand on quitte la page sans sauvegarder ([#875](https://github.com/DISIC/Ara/pull/875))
- Corrige un bug lié à l'ancienne gestion des critères transverses provoquant parfois des écrasenements de données ([#876](https://github.com/DISIC/Ara/pull/876))

## 07/11/2024

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
Warnings:
- You are about to drop the column `transverse` on the `CriterionResult` table. All the data in the column will be lost.
*/
-- AlterTable
ALTER TABLE "CriterionResult" DROP COLUMN "transverse";
44 changes: 21 additions & 23 deletions confiture-rest-api/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ model Audit {
/// @DtoEntityHidden
pages AuditedPage[] @relation("UserPages")
// single page for transverse elements
transverseElementsPage AuditedPage @relation("TransversePage", fields: [transverseElementsPageId], references: [id])
transverseElementsPageId Int @unique
transverseElementsPage AuditedPage @relation("TransversePage", fields: [transverseElementsPageId], references: [id])
transverseElementsPageId Int @unique
auditorName String?
auditorEmail String?
showAuditorEmailInReport Boolean @default(false)
Expand Down Expand Up @@ -96,11 +96,11 @@ model Audit {
}

model TestEnvironment {
id Int @id @default(autoincrement())
platform String
operatingSystem String
assistiveTechnology String
browser String
id Int @id @default(autoincrement())
platform String
operatingSystem String
assistiveTechnology String
browser String
audit Audit? @relation(fields: [auditUniqueId], references: [editUniqueId], onDelete: Cascade)
auditUniqueId String?
Expand All @@ -121,15 +121,13 @@ model AuditedPage {
// parent audit when the page is a transverse page
auditTransverse Audit? @relation(name: "TransversePage")
results CriterionResult[]
}

model CriterionResult {
id Int @id @default(autoincrement())
status CriterionResultStatus @default(NOT_TESTED)
transverse Boolean @default(false)
status CriterionResultStatus @default(NOT_TESTED)
compliantComment String?
Expand Down Expand Up @@ -175,15 +173,15 @@ model StoredFile {
id Int @id @default(autoincrement())
originalFilename String
// The default mimetype set to "image/unknown" to handle existing files
// in the DB (before the property has been added).
// Originally, all files were images.
mimetype String @default("image/unknown")
// The default mimetype set to "image/unknown" to handle existing files
// in the DB (before the property has been added).
// Originally, all files were images.
mimetype String @default("image/unknown")
size Int
size Int
// S3 storage keys
key String
key String
thumbnailKey String
criterionResult CriterionResult? @relation(fields: [criterionResultId], references: [id], onDelete: Cascade, onUpdate: Cascade)
Expand All @@ -194,18 +192,18 @@ model AuditFile {
id Int @id @default(autoincrement())
originalFilename String
// The default mimetype set to "image/unknown" to handle existing files
// in the DB (before the property has been added).
// Originally, all files were images.
mimetype String @default("image/unknown")
// The default mimetype set to "image/unknown" to handle existing files
// in the DB (before the property has been added).
// Originally, all files were images.
mimetype String @default("image/unknown")
size Int
size Int
// S3 storage key
key String
key String
thumbnailKey String?
audit Audit? @relation(fields: [auditUniqueId], references: [editUniqueId], onDelete: Cascade)
audit Audit? @relation(fields: [auditUniqueId], references: [editUniqueId], onDelete: Cascade)
auditUniqueId String?
}

Expand Down
62 changes: 1 addition & 61 deletions confiture-rest-api/src/audits/audit.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ export class AuditService {
userImpact: null,
notApplicableComment: null,
exampleImages: [],
transverse: false,
quickWin: false,

topic: criterion.topic,
Expand Down Expand Up @@ -371,10 +370,6 @@ export class AuditService {
}

async updateResults(uniqueId: string, body: UpdateResultsDto) {
const pages = await this.prisma.auditedPage.findMany({
where: { auditUniqueId: uniqueId }
});

const promises = body.data
.map((item) => {
const data: Prisma.CriterionResultUpsertArgs["create"] = {
Expand All @@ -391,19 +386,12 @@ export class AuditService {
notCompliantComment: item.notCompliantComment,
notApplicableComment: item.notApplicableComment,
userImpact: item.userImpact,
quickWin: item.quickWin,
transverse: item.transverse
quickWin: item.quickWin
};

const result = [
this.prisma.criterionResult.upsert({
where: {
// auditUniqueId_pageUrl_topic_criterium: {
// auditUniqueId: uniqueId,
// criterium: item.criterium,
// pageUrl: item.pageUrl,
// topic: item.topic,
// },
pageId_topic_criterium: {
criterium: item.criterium,
topic: item.topic,
Expand All @@ -415,53 +403,6 @@ export class AuditService {
})
];

if (item.transverse) {
pages
.filter((page) => page.id !== item.pageId)
.forEach((page) => {
const data: Prisma.CriterionResultUpsertArgs["create"] = {
criterium: item.criterium,
topic: item.topic,
page: {
connect: {
id: page.id
}
},

status: item.status,
transverse: true,

...(item.status === CriterionResultStatus.COMPLIANT && {
compliantComment: item.compliantComment
}),

...(item.status === CriterionResultStatus.NOT_COMPLIANT && {
notCompliantComment: item.notCompliantComment,
userImpact: item.userImpact,
quickWin: item.quickWin
}),

...(item.status === CriterionResultStatus.NOT_APPLICABLE && {
notApplicableComment: item.notApplicableComment
})
};

result.push(
this.prisma.criterionResult.upsert({
where: {
pageId_topic_criterium: {
criterium: item.criterium,
topic: item.topic,
pageId: page.id
}
},
create: data,
update: data
})
);
});
}

return result;
})
.flat();
Expand Down Expand Up @@ -1049,7 +990,6 @@ export class AuditService {
criterium: r.criterium,

status: r.status,
transverse: r.transverse,

compliantComment: r.compliantComment,
notCompliantComment: r.notCompliantComment,
Expand Down
2 changes: 0 additions & 2 deletions confiture-rest-api/src/audits/dto/audit-report.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,6 @@ class ReportCriterionResult {
@ApiProperty({ enum: CriterionResultStatus })
status: CriterionResultStatus;

transverse: boolean;

compliantComment: string | null;

/**
Expand Down
7 changes: 0 additions & 7 deletions confiture-rest-api/src/audits/dto/update-results.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,6 @@ class UpdateResultsItem {
@IsIn(Object.values(CriterionResultStatus))
status: CriterionResultStatus;

/**
* Whether the status is the same on all pages
*/
@IsBoolean()
@IsOptional()
transverse?: boolean;

/**
* @example "Ad culpa cupidatat proident amet ullamco proident proident mollit ipsum enim consectetur consequat labore."
*/
Expand Down
2 changes: 1 addition & 1 deletion confiture-web-app/src/components/audit/DuplicateModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function handleClose() {
ref="duplicateAuditNameRef"
v-model="duplicateAuditName"
label="Nom de la copie"
:hint="`Exemple : contre audit ${
:hint="`Exemple : contre-audit ${
originalAuditName ?? 'site DesignGouv'
}`"
type="text"
Expand Down
1 change: 0 additions & 1 deletion confiture-web-app/src/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ export interface CriteriumResult {

// DATA
status: CriteriumResultStatus;
transverse: boolean;

compliantComment: string | null;
notCompliantComment: string | null;
Expand Down

0 comments on commit 56158d9

Please sign in to comment.