mirror of
https://github.com/lukevella/rallly.git
synced 2025-07-21 18:27:53 +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 = [];
|
||||
for (let i = 0; i < existingOptions.length; i++) {
|
||||
const legacyOption = legacyPoll.dates?.find(
|
||||
(date) =>
|
||||
date.toISOString().substring(0, 10) === existingOptions[i].value,
|
||||
);
|
||||
if (legacyOption) {
|
||||
promises.push(
|
||||
prisma.option.update({
|
||||
where: { id: existingOptions[i].id },
|
||||
data: {
|
||||
value: legacyOption.toISOString(),
|
||||
},
|
||||
}),
|
||||
const existingOption = existingOptions[i];
|
||||
if (existingOption.value.indexOf("T") === -1) {
|
||||
const legacyOption = legacyPoll.dates?.find(
|
||||
(date) => date.toISOString().substring(0, 10) === existingOption.value,
|
||||
);
|
||||
if (legacyOption) {
|
||||
promises.push(
|
||||
prisma.option.update({
|
||||
where: { id: existingOption.id },
|
||||
data: {
|
||||
value: legacyOption.toISOString(),
|
||||
},
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
await prisma.$transaction(promises);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue