mirror of
https://github.com/OneUptime/oneuptime
synced 2024-11-22 15:24:55 +00:00
48 lines
1.7 KiB
TypeScript
48 lines
1.7 KiB
TypeScript
import RunCron from '../../Utils/Cron';
|
|
import { EVERY_MINUTE } from 'Common/Utils/CronTime';
|
|
import LIMIT_MAX from 'Common/Types/Database/LimitMax';
|
|
import MonitorService from 'CommonServer/Services/MonitorService';
|
|
import MonitorType from 'Common/Types/Monitor/MonitorType';
|
|
import ProbeMonitorResponseService from 'CommonServer/Utils/Probe/ProbeMonitorResponse';
|
|
import IncomingMonitorRequest from 'Common/Types/Monitor/IncomingMonitor/IncomingMonitorRequest';
|
|
import Monitor from 'Model/Models/Monitor';
|
|
|
|
RunCron(
|
|
'HardDelete:HardDeleteItemsInDatabase',
|
|
{ schedule: EVERY_MINUTE, runOnStartup: false },
|
|
async () => {
|
|
const incomingRequestMonitors: Array<Monitor> =
|
|
await MonitorService.findBy({
|
|
query: {
|
|
monitorType: MonitorType.IncomingRequest,
|
|
},
|
|
props: {
|
|
isRoot: true,
|
|
},
|
|
select: {
|
|
_id: true,
|
|
monitorSteps: true,
|
|
incomingRequestReceivedAt: true,
|
|
createdAt: true,
|
|
},
|
|
limit: LIMIT_MAX,
|
|
skip: 0,
|
|
});
|
|
|
|
for (const monitor of incomingRequestMonitors) {
|
|
const incomingRequest: IncomingMonitorRequest = {
|
|
monitorId: monitor.id!,
|
|
requestHeaders: undefined,
|
|
requestBody: undefined,
|
|
incomingRequestReceivedAt:
|
|
monitor.incomingRequestReceivedAt || monitor.createdAt!,
|
|
onlyCheckForIncomingRequestReceivedAt: true,
|
|
};
|
|
|
|
await ProbeMonitorResponseService.processProbeResponse(
|
|
incomingRequest
|
|
);
|
|
}
|
|
}
|
|
);
|