try to deploy

Signed-off-by: Kenneth Obsequio <k80308392@gmail.com>
This commit is contained in:
2026-07-13 21:27:37 +08:00
parent f5254f7571
commit c8dc2628a6
9 changed files with 120 additions and 46 deletions
+10 -2
View File
@@ -315,7 +315,11 @@ exports.archiveAdvertisement = async (req, res) => {
const advertisement = await Advertisement.findOne({ where: { advertisement_id: advertisementId, ...notDeleted } });
if (!advertisement) return R.error(res, "Advertisement not found.", 404);
await advertisement.update({ deletedBy: req.body.deletedBy ?? null });
// Freeze the derived status (e.g. "expired") onto the row before it goes
// paranoid — the archived list trusts this stored value as-is and never
// re-derives it, so "Remove Expired" would otherwise miss ads that had
// already lapsed at the moment an admin manually archived them.
await advertisement.update({ deletedBy: req.body.deletedBy ?? null, status: deriveStatus(advertisement) });
await advertisement.destroy();
logActivity(req.user?.user_id, 'archive_advertisement', { entityType: 'advertisement', entityId: Number(advertisementId) });
return R.success(res, "Advertisement archived.");
@@ -337,7 +341,11 @@ exports.archiveAdvertisements = async (req, res) => {
const activeIds = advertisements.map((a) => a.advertisement_id);
await Advertisement.update({ deletedBy: deletedBy ?? null }, { where: { advertisement_id: { [Op.in]: activeIds } } });
// Same status-freeze as the single-archive path — resync each row's
// status right before it goes paranoid so "Remove Expired" can trust it.
await Promise.all(advertisements.map((a) =>
a.update({ deletedBy: deletedBy ?? null, status: deriveStatus(a) })
));
await Advertisement.destroy({ where: { advertisement_id: { [Op.in]: activeIds } } });
logActivity(req.user?.user_id, 'bulk_archive_advertisements', { entityType: 'advertisement', details: { ids: activeIds, count: activeIds.length } });