mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-04-06 00:32:12 +02:00
refactor(worker,server): remove unused import, add missing LIMIT_PER_PROJECT import, and normalize object literal formatting
This commit is contained in:
@@ -1446,8 +1446,9 @@ export class ProjectService extends DatabaseService<Model> {
|
||||
}): Promise<Array<Model>> {
|
||||
const select: Select<Model> | undefined =
|
||||
params?.select || ({ _id: true } as Select<Model>);
|
||||
const props: DatabaseCommonInteractionProps =
|
||||
params?.props || { isRoot: true };
|
||||
const props: DatabaseCommonInteractionProps = params?.props || {
|
||||
isRoot: true,
|
||||
};
|
||||
|
||||
return await this.findAllBy({
|
||||
query: this.getActiveProjectStatusQuery(),
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import RunCron from "../../Utils/Cron";
|
||||
import { FileRoute } from "Common/ServiceRoute";
|
||||
import Hostname from "Common/Types/API/Hostname";
|
||||
import Protocol from "Common/Types/API/Protocol";
|
||||
import URL from "Common/Types/API/URL";
|
||||
|
||||
@@ -12,12 +12,13 @@ RunCron(
|
||||
async () => {
|
||||
try {
|
||||
// get all projects, then get all incidents for each project, then refresh the current state of each incident.
|
||||
const projects: Array<Project> = await ProjectService.getAllActiveProjects({
|
||||
select: {
|
||||
_id: true,
|
||||
},
|
||||
skip: 0,
|
||||
});
|
||||
const projects: Array<Project> =
|
||||
await ProjectService.getAllActiveProjects({
|
||||
select: {
|
||||
_id: true,
|
||||
},
|
||||
skip: 0,
|
||||
});
|
||||
|
||||
for (const project of projects) {
|
||||
try {
|
||||
|
||||
@@ -49,8 +49,8 @@ RunCron(
|
||||
},
|
||||
});
|
||||
|
||||
const incomingRequestMonitors: Array<Monitor> = await MonitorService.findAllBy(
|
||||
{
|
||||
const incomingRequestMonitors: Array<Monitor> =
|
||||
await MonitorService.findAllBy({
|
||||
query: {
|
||||
...MonitorService.getEnabledMonitorQuery(),
|
||||
monitorType: MonitorType.IncomingRequest,
|
||||
@@ -73,8 +73,7 @@ RunCron(
|
||||
sort: {
|
||||
incomingRequestMonitorHeartbeatCheckedAt: SortOrder.Ascending,
|
||||
},
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
const totalIncomingRequestMonitors: Array<Monitor> = [
|
||||
...newIncomingRequestMonitors,
|
||||
|
||||
@@ -24,16 +24,17 @@ RunCron(
|
||||
// get time logs older than 6 months. EndsAt is more than 6 months ago.
|
||||
|
||||
while (true) {
|
||||
const deletedCount: number = await OnCallDutyPolicyTimeLogService.deleteBy({
|
||||
query: {
|
||||
endsAt: QueryHelper.lessThanEqualTo(sixMonthsAgo),
|
||||
},
|
||||
props: {
|
||||
isRoot: true,
|
||||
},
|
||||
limit: TIME_LOG_DELETE_BATCH_SIZE,
|
||||
skip: 0,
|
||||
});
|
||||
const deletedCount: number =
|
||||
await OnCallDutyPolicyTimeLogService.deleteBy({
|
||||
query: {
|
||||
endsAt: QueryHelper.lessThanEqualTo(sixMonthsAgo),
|
||||
},
|
||||
props: {
|
||||
isRoot: true,
|
||||
},
|
||||
limit: TIME_LOG_DELETE_BATCH_SIZE,
|
||||
skip: 0,
|
||||
});
|
||||
|
||||
if (deletedCount === 0) {
|
||||
break;
|
||||
|
||||
@@ -38,22 +38,21 @@ RunCron(
|
||||
skip: 0,
|
||||
});
|
||||
|
||||
const subscriptionPastdue: Array<Project> =
|
||||
await ProjectService.findAllBy({
|
||||
query: {
|
||||
paymentProviderSubscriptionStatus: SubscriptionStatus.PastDue,
|
||||
},
|
||||
select: {
|
||||
_id: true,
|
||||
paymentProviderSubscriptionId: true,
|
||||
paymentProviderMeteredSubscriptionId: true,
|
||||
},
|
||||
props: {
|
||||
isRoot: true,
|
||||
ignoreHooks: true,
|
||||
},
|
||||
skip: 0,
|
||||
});
|
||||
const subscriptionPastdue: Array<Project> = await ProjectService.findAllBy({
|
||||
query: {
|
||||
paymentProviderSubscriptionStatus: SubscriptionStatus.PastDue,
|
||||
},
|
||||
select: {
|
||||
_id: true,
|
||||
paymentProviderSubscriptionId: true,
|
||||
paymentProviderMeteredSubscriptionId: true,
|
||||
},
|
||||
props: {
|
||||
isRoot: true,
|
||||
ignoreHooks: true,
|
||||
},
|
||||
skip: 0,
|
||||
});
|
||||
|
||||
const allPastDueProjects: Array<Project> = [
|
||||
...merteredSubscriptionPastdue,
|
||||
|
||||
@@ -13,6 +13,7 @@ import UserNotificationRule from "Common/Models/DatabaseModels/UserNotificationR
|
||||
import UserOnCallLog from "Common/Models/DatabaseModels/UserOnCallLog";
|
||||
import Alert from "Common/Models/DatabaseModels/Alert";
|
||||
import AlertService from "Common/Server/Services/AlertService";
|
||||
import { LIMIT_PER_PROJECT } from "Common/Types/Database/LimitMax";
|
||||
|
||||
RunCron(
|
||||
"UserOnCallLog:ExecutePendingExecutions",
|
||||
|
||||
Reference in New Issue
Block a user