diff --git a/CHANGELOG.md b/CHANGELOG.md index c08f07c9..04a329d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ Tous les changements notables de Ara sont documentés ici avec leur date, leur catégorie (nouvelle fonctionnalité, correction de bug ou autre changement) et leur pull request (PR) associée. +## 15/11/2024 + +### Corrections 🐛 + +- 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 ### Corrections 🐛 diff --git a/confiture-rest-api/prisma/migrations/20241114150438_remove_result_transverse/migration.sql b/confiture-rest-api/prisma/migrations/20241114150438_remove_result_transverse/migration.sql new file mode 100644 index 00000000..c4850566 --- /dev/null +++ b/confiture-rest-api/prisma/migrations/20241114150438_remove_result_transverse/migration.sql @@ -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"; diff --git a/confiture-rest-api/prisma/schema.prisma b/confiture-rest-api/prisma/schema.prisma index cbf4388e..3c1a51b2 100644 --- a/confiture-rest-api/prisma/schema.prisma +++ b/confiture-rest-api/prisma/schema.prisma @@ -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) @@ -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? @@ -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? @@ -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) @@ -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? } diff --git a/confiture-rest-api/src/audits/audit.service.ts b/confiture-rest-api/src/audits/audit.service.ts index e1ab4d59..f613c9e8 100644 --- a/confiture-rest-api/src/audits/audit.service.ts +++ b/confiture-rest-api/src/audits/audit.service.ts @@ -204,7 +204,6 @@ export class AuditService { userImpact: null, notApplicableComment: null, exampleImages: [], - transverse: false, quickWin: false, topic: criterion.topic, @@ -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"] = { @@ -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, @@ -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(); @@ -1049,7 +990,6 @@ export class AuditService { criterium: r.criterium, status: r.status, - transverse: r.transverse, compliantComment: r.compliantComment, notCompliantComment: r.notCompliantComment, diff --git a/confiture-rest-api/src/audits/dto/audit-report.dto.ts b/confiture-rest-api/src/audits/dto/audit-report.dto.ts index 7e70d9a9..0ac3e5be 100644 --- a/confiture-rest-api/src/audits/dto/audit-report.dto.ts +++ b/confiture-rest-api/src/audits/dto/audit-report.dto.ts @@ -173,8 +173,6 @@ class ReportCriterionResult { @ApiProperty({ enum: CriterionResultStatus }) status: CriterionResultStatus; - transverse: boolean; - compliantComment: string | null; /** diff --git a/confiture-rest-api/src/audits/dto/update-results.dto.ts b/confiture-rest-api/src/audits/dto/update-results.dto.ts index bb040f8e..862e28ea 100644 --- a/confiture-rest-api/src/audits/dto/update-results.dto.ts +++ b/confiture-rest-api/src/audits/dto/update-results.dto.ts @@ -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." */ diff --git a/confiture-web-app/src/types/types.ts b/confiture-web-app/src/types/types.ts index 9da7167c..fc48a08d 100644 --- a/confiture-web-app/src/types/types.ts +++ b/confiture-web-app/src/types/types.ts @@ -123,7 +123,6 @@ export interface CriteriumResult { // DATA status: CriteriumResultStatus; - transverse: boolean; compliantComment: string | null; notCompliantComment: string | null;