Skip to content

Commit

Permalink
Corrige un bug rendant impossible la duplication d'un audit contenant…
Browse files Browse the repository at this point in the history
… des images d'exemple pour des critères transverses (#836)

* fix transverse example images causing errors when duplicating audit

* update changelog
  • Loading branch information
hissalht authored Oct 31, 2024
1 parent d512590 commit 5ee6d96
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 30 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

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.

## 31/10/2024

- Corrige un bug rendant impossible la duplication d'un audit contenant des images d'exemple pour des critères transverses ([#836](https://github.com/DISIC/Ara/pull/836))

## 18/10/2024

### Autres changements ⚙️
Expand Down
62 changes: 32 additions & 30 deletions confiture-rest-api/src/audits/audit.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1168,40 +1168,42 @@ export class AuditService {
const fileDuplications: { originalKey: string; destinationKey: string }[] =
[];

originalAudit.pages.forEach((p) => {
p.results.forEach((r) => {
r.exampleImages.forEach((e) => {
const randomPrefix = nanoid();
[...originalAudit.pages, originalAudit.transverseElementsPage].forEach(
(p) => {
p.results.forEach((r) => {
r.exampleImages.forEach((e) => {
const randomPrefix = nanoid();

const key = `audits/${duplicateEditUniqueId}/${randomPrefix}/${e.originalFilename}`;
const thumbnailKey = `audits/${duplicateEditUniqueId}/${randomPrefix}/thumbnail_${e.originalFilename}`;
const key = `audits/${duplicateEditUniqueId}/${randomPrefix}/${e.originalFilename}`;
const thumbnailKey = `audits/${duplicateEditUniqueId}/${randomPrefix}/thumbnail_${e.originalFilename}`;

fileDuplications.push(
{
originalKey: e.key,
destinationKey: key
},
{
originalKey: e.thumbnailKey,
destinationKey: thumbnailKey
}
);
fileDuplications.push(
{
originalKey: e.key,
destinationKey: key
},
{
originalKey: e.thumbnailKey,
destinationKey: thumbnailKey
}
);

setWith(
imagesCreateData,
[p.id, r.id, e.id],
{
originalFilename: e.originalFilename,
mimetype: e.mimetype,
size: e.size,
key: key,
thumbnailKey: thumbnailKey
},
Object
);
setWith(
imagesCreateData,
[p.id, r.id, e.id],
{
originalFilename: e.originalFilename,
mimetype: e.mimetype,
size: e.size,
key: key,
thumbnailKey: thumbnailKey
},
Object
);
});
});
});
});
}
);

originalAudit.notesFiles.forEach((e) => {
const randomPrefix = nanoid();
Expand Down

0 comments on commit 5ee6d96

Please sign in to comment.