Skip to content

Commit 8a6673a

Browse files
authored
Merge pull request #385 from openscript-ch/384-templates-not-generated-for-entries-of-first-questionnaire
384 templates not generated for entries of first questionnaire
2 parents a743590 + 1780a8d commit 8a6673a

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

.changeset/tired-clubs-bow.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@quassel/backend": patch
3+
---
4+
5+
Fix creating language entries when creating for multiple days

apps/backend/src/research/entries/entries.service.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,18 @@ export class EntriesService {
1313
private readonly em: EntityManager
1414
) {}
1515

16-
create({ weekday, ...rest }: EntryCreationDto) {
17-
return this.entryRepository.insertMany(
18-
weekday.map((w) => {
19-
const entry = new Entry();
20-
entry.assign({ weekday: w, ...rest }, { em: this.em });
21-
22-
return entry;
23-
})
24-
);
16+
async create({ weekday, ...rest }: EntryCreationDto) {
17+
const entries = weekday.map((w) => {
18+
const entry = new Entry();
19+
entry.assign({ ...rest, weekday: w }, { em: this.em });
20+
21+
this.em.persist(entry);
22+
return entry;
23+
});
24+
25+
await this.em.flush();
26+
27+
return entries.map((entries) => entries.toObject().id);
2528
}
2629

2730
async findAll() {

0 commit comments

Comments
 (0)