Skip to content

Commit c2e44b3

Browse files
authored
Merge pull request #2325 from Giveth/fix/bump-updatedat-on-project-status-changes
Bump updatedAt on every project status change
2 parents 9c76e19 + 17c8b94 commit c2e44b3

2 files changed

Lines changed: 21 additions & 3 deletions

File tree

src/repositories/projectRepository.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -700,10 +700,14 @@ export const totalProjectsPerDateByMonthAndYear = async (
700700
};
701701

702702
export const makeProjectListed = async (id: number): Promise<void> => {
703+
// updatedAt bump is required so giveth-v6-core's legacy sync recognizes this
704+
// change as newer than its mirror row. Without it, the v6 row's updated_at
705+
// stays ahead and the next v5→v6 pull skips the update.
703706
await Project.createQueryBuilder('broadcast_notification')
704707
.update<Project>(Project, {
705708
listed: true,
706709
reviewStatus: ReviewStatus.Listed,
710+
updatedAt: new Date(),
707711
})
708712
.where(`id =${id}`)
709713
.updateEntity(true)

src/server/adminJs/tabs/projectsTab.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,10 @@ export const verifyProjects = async (
262262
}
263263
}
264264

265-
const updateParams = { verified: vouchedStatus };
265+
// updatedAt bump keeps giveth-v6-core's legacy sync timestamp guard
266+
// aligned; .createQueryBuilder().update() bypasses TypeORM entity hooks
267+
// so we set it explicitly here.
268+
const updateParams = { verified: vouchedStatus, updatedAt: new Date() };
266269

267270
// Perform the update
268271
await Project.createQueryBuilder('project')
@@ -352,7 +355,10 @@ export const updateStatusOfProjects = async (
352355
where: { id: status },
353356
});
354357
if (projectStatus) {
355-
const updateData: any = { status: projectStatus };
358+
// updatedAt bump keeps giveth-v6-core's legacy sync timestamp guard
359+
// aligned; .createQueryBuilder().update() bypasses TypeORM entity hooks
360+
// so we set it explicitly here.
361+
const updateData: any = { status: projectStatus, updatedAt: new Date() };
356362
if (status === ProjStatus.cancelled || status === ProjStatus.deactive) {
357363
updateData.listed = false;
358364
updateData.reviewStatus = ReviewStatus.NotListed;
@@ -600,8 +606,11 @@ export const listDelist = async (
600606
?.split(',')
601607
?.map(strId => Number(strId)) as number[];
602608
const projectsBeforeUpdating = await findProjectsByIdArray(projectIds);
609+
// updatedAt bump keeps giveth-v6-core's legacy sync timestamp guard
610+
// aligned; .createQueryBuilder().update() bypasses TypeORM entity hooks
611+
// so we set it explicitly here.
603612
const projects = await Project.createQueryBuilder('project')
604-
.update<Project>(Project, { reviewStatus, listed })
613+
.update<Project>(Project, { reviewStatus, listed, updatedAt: new Date() })
605614
.where('project.id IN (:...ids)')
606615
.setParameter('ids', projectIds)
607616
.returning('*')
@@ -1121,6 +1130,7 @@ export const projectsTab = {
11211130
where: { id: request?.record?.params?.newAdminId },
11221131
});
11231132
project.adminUser = adminUser!;
1133+
project.updatedAt = new Date();
11241134
await project.save();
11251135

11261136
// Update project verification form owner if it has been changed
@@ -1234,6 +1244,7 @@ export const projectsTab = {
12341244
statusChanges?.includes(NOTIFICATIONS_EVENT_NAMES.PROJECT_LISTED)
12351245
) {
12361246
project.listed = true;
1247+
project.updatedAt = new Date();
12371248
await project.save();
12381249
}
12391250

@@ -1243,6 +1254,7 @@ export const projectsTab = {
12431254
)
12441255
) {
12451256
project.listed = false;
1257+
project.updatedAt = new Date();
12461258
await project.save();
12471259
}
12481260

@@ -1252,6 +1264,7 @@ export const projectsTab = {
12521264
)
12531265
) {
12541266
project.listed = null;
1267+
project.updatedAt = new Date();
12551268
await project.save();
12561269
}
12571270

@@ -1424,5 +1437,6 @@ async function saveCategories(project: Project, categoryIds?: string[]) {
14241437
.getMany();
14251438

14261439
project.categories = categories;
1440+
project.updatedAt = new Date();
14271441
await project.save();
14281442
}

0 commit comments

Comments
 (0)