mirror of
https://github.com/lukevella/rallly.git
synced 2025-07-22 18:57:23 +02:00
Automatically reset legacy poll date values
This commit is contained in:
parent
4898b75f9b
commit
c9aaddf4cc
1 changed files with 14 additions and 12 deletions
|
@ -66,19 +66,21 @@ export const resetDates = async (legacyPollId: string) => {
|
||||||
|
|
||||||
const promises = [];
|
const promises = [];
|
||||||
for (let i = 0; i < existingOptions.length; i++) {
|
for (let i = 0; i < existingOptions.length; i++) {
|
||||||
const legacyOption = legacyPoll.dates?.find(
|
const existingOption = existingOptions[i];
|
||||||
(date) =>
|
if (existingOption.value.indexOf("T") === -1) {
|
||||||
date.toISOString().substring(0, 10) === existingOptions[i].value,
|
const legacyOption = legacyPoll.dates?.find(
|
||||||
);
|
(date) => date.toISOString().substring(0, 10) === existingOption.value,
|
||||||
if (legacyOption) {
|
|
||||||
promises.push(
|
|
||||||
prisma.option.update({
|
|
||||||
where: { id: existingOptions[i].id },
|
|
||||||
data: {
|
|
||||||
value: legacyOption.toISOString(),
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
);
|
);
|
||||||
|
if (legacyOption) {
|
||||||
|
promises.push(
|
||||||
|
prisma.option.update({
|
||||||
|
where: { id: existingOption.id },
|
||||||
|
data: {
|
||||||
|
value: legacyOption.toISOString(),
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await prisma.$transaction(promises);
|
await prisma.$transaction(promises);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue