refactor(worker,server): remove unused import, add missing LIMIT_PER_PROJECT import, and normalize object literal formatting

This commit is contained in:
Nawaz Dhandala
2025-10-28 15:00:24 +00:00
parent e212079b4a
commit 819bd54a1f
7 changed files with 40 additions and 39 deletions

View File

@@ -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(),

View File

@@ -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";

View File

@@ -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 {

View File

@@ -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,

View File

@@ -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;

View File

@@ -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,

View File

@@ -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",