feat(tms): a clean up function was added to remove releases added as blockers older than 45d

This commit is contained in:
2025-08-21 05:10:25 -05:00
parent 0c54cecbd4
commit 662a951b98

View File

@@ -276,16 +276,28 @@ export const tiImport = async () => {
* Update the db so we dont try to pull the next one
*/
const currentDate = new Date(Date.now());
const uniqueOrders = Array.from(
new Set([
...notiSet[0].notifiySettings.releases,
{
releaseNumber: header[0].releaseNumber,
timeStamp: new Date(Date.now()),
timeStamp: currentDate,
},
])
);
// 45 days ago
const dateLimit = new Date(
currentDate.getTime() - 45 * 24 * 60 * 60 * 1000
);
// filter dates
let filteredOrders = uniqueOrders.filter((item) => {
const time = new Date(item.timeStamp).getTime();
return time >= dateLimit.getTime();
});
const { data, error } = await tryCatch(
db
.update(notifications)
@@ -293,7 +305,7 @@ export const tiImport = async () => {
lastRan: sql`NOW()`,
notifiySettings: {
...notiSet[0].notifiySettings,
releases: uniqueOrders,
releases: filteredOrders,
},
})
.where(eq(notifications.name, "tiIntergration"))