refactor: Update import statements for TimezoneUtil in multiple files

This commit is contained in:
Simon Larsen
2024-06-17 15:58:30 +01:00
parent 49b6550581
commit 2615e39c19
7 changed files with 44 additions and 54 deletions

View File

@@ -129,10 +129,7 @@ RunCron(
continue;
}
for (const user of owners) {
const vars: Dictionary<string> = {
incidentTitle: incident.title!,
projectName: incidentStateTimeline.project!.name!,
@@ -147,12 +144,11 @@ RunCron(
return monitor.name!;
})
.join(", ") || "None",
stateChangedAt: OneUptimeDate.getDateAsFormattedHTMLInMultipleTimezones(
{
stateChangedAt:
OneUptimeDate.getDateAsFormattedHTMLInMultipleTimezones({
date: incidentStateTimeline.createdAt!,
timezones: user.timezone ? [user.timezone] : []
}
),
timezones: user.timezone ? [user.timezone] : [],
}),
incidentSeverity: incidentWithSeverity.incidentSeverity!.name!,
incidentViewLink: (
await IncidentService.getIncidentLinkInDashboard(
@@ -161,7 +157,7 @@ RunCron(
)
).toString(),
};
if (doesResourceHasOwners === true) {
vars["isOwner"] = "true";
}

View File

@@ -86,11 +86,7 @@ RunCron(
continue;
}
for (const user of owners) {
const vars: Dictionary<string> = {
monitorName: monitor.name!,
projectName: monitorStatusTimeline.project!.name!,
@@ -102,8 +98,8 @@ RunCron(
statusChangedAt:
OneUptimeDate.getDateAsFormattedHTMLInMultipleTimezones({
date: monitorStatusTimeline.createdAt!,
timezones: user.timezone ? [user.timezone] : []
}),
timezones: user.timezone ? [user.timezone] : [],
}),
monitorViewLink: (
await MonitorService.getMonitorLinkInDashboard(
monitorStatusTimeline.projectId!,
@@ -113,7 +109,7 @@ RunCron(
rootCause:
monitorStatusTimeline.rootCause || "No root cause identified.",
};
if (doesResourceHasOwners === true) {
vars["isOwner"] = "true";
}

View File

@@ -189,10 +189,11 @@ RunCron(
${event.title || ""}
${resourcesAffected
? "Resources Affected: " + resourcesAffected
: ""
}
${
resourcesAffected
? "Resources Affected: " + resourcesAffected
: ""
}
To view this event, visit ${statusPageURL}
@@ -225,9 +226,9 @@ RunCron(
statusPageUrl: statusPageURL,
logoUrl: statuspage.logoFileId
? new URL(httpProtocol, host)
.addRoute(FileRoute)
.addRoute("/image/" + statuspage.logoFileId)
.toString()
.addRoute(FileRoute)
.addRoute("/image/" + statuspage.logoFileId)
.toString()
: "",
isPublicStatusPage: statuspage.isPublicStatusPage
? "true"

View File

@@ -90,10 +90,7 @@ RunCron(
continue;
}
for (const user of owners) {
const vars: Dictionary<string> = {
scheduledMaintenanceTitle: scheduledMaintenance.title!,
projectName: scheduledMaintenanceStateTimeline.project!.name!,
@@ -102,10 +99,11 @@ RunCron(
scheduledMaintenance.description! || "",
MarkdownContentType.Email,
),
stateChangedAt: OneUptimeDate.getDateAsFormattedHTMLInMultipleTimezones({
date: scheduledMaintenanceStateTimeline.createdAt!,
timezones: user.timezone ? [user.timezone] : []
}),
stateChangedAt:
OneUptimeDate.getDateAsFormattedHTMLInMultipleTimezones({
date: scheduledMaintenanceStateTimeline.createdAt!,
timezones: user.timezone ? [user.timezone] : [],
}),
scheduledMaintenanceViewLink: (
await ScheduledMaintenanceService.getScheduledMaintenanceLinkInDashboard(
scheduledMaintenanceStateTimeline.projectId!,
@@ -113,7 +111,7 @@ RunCron(
)
).toString(),
};
if (doesResourceHasOwners === true) {
vars["isOwner"] = "true";
}

View File

@@ -318,8 +318,8 @@ export default class OneUptimeDate {
type TenFunction = (i: number) => string;
const ten: TenFunction = (i: number): string => {
return (i < 10 ? "0" : "") + i;
},
return (i < 10 ? "0" : "") + i;
},
YYYY: number = date.getFullYear(),
MM: string = ten(date.getMonth() + 1),
DD: string = ten(date.getDate()),
@@ -903,11 +903,10 @@ export default class OneUptimeDate {
}
public static getDateAsFormattedArrayInMultipleTimezones(data: {
date: string | Date,
onlyShowDate?: boolean | undefined,
date: string | Date;
onlyShowDate?: boolean | undefined;
timezones?: Array<Timezone> | undefined;
}): Array<string> {
let date: string | Date = data.date;
const onlyShowDate: boolean | undefined = data.onlyShowDate;
let timezones: Array<Timezone> | undefined = data.timezones;
@@ -930,28 +929,29 @@ export default class OneUptimeDate {
Timezone.AmericaLos_Angeles,
Timezone.AsiaKolkata,
Timezone.AustraliaSydney,
] // default timezones.
]; // default timezones.
}
for (let i = 0; i < timezones.length; i++) {
for (let i: number = 0; i < timezones.length; i++) {
timezoneDates.push(
moment(date).tz(timezones[i] as string).format(formatstring) +
" " +
(onlyShowDate ? "" : this.getZoneAbbrByTimezone(timezones[i] as Timezone)),
moment(date)
.tz(timezones[i] as string)
.format(formatstring) +
" " +
(onlyShowDate
? ""
: this.getZoneAbbrByTimezone(timezones[i] as Timezone)),
);
}
return timezoneDates;
}
public static getDateAsFormattedHTMLInMultipleTimezones(data: {
date: string | Date,
onlyShowDate?: boolean,
timezones?: Array<Timezone> | undefined, // if this is skipped, then it will show the default timezones in the order of UTC, EST, PST, IST, ACT
date: string | Date;
onlyShowDate?: boolean;
timezones?: Array<Timezone> | undefined; // if this is skipped, then it will show the default timezones in the order of UTC, EST, PST, IST, ACT
}): string {
const date: string | Date = data.date;
const onlyShowDate: boolean | undefined = data.onlyShowDate;
const timezones: Array<Timezone> | undefined = data.timezones;
@@ -959,16 +959,15 @@ export default class OneUptimeDate {
return this.getDateAsFormattedArrayInMultipleTimezones({
date,
onlyShowDate,
timezones
timezones,
}).join("<br/>");
}
public static getDateAsFormattedStringInMultipleTimezones(data: {
date: string | Date,
onlyShowDate?: boolean | undefined,
timezones?: Array<Timezone> | undefined, // if this is skipped, then it will show the default timezones in the order of UTC, EST, PST, IST, ACT
date: string | Date;
onlyShowDate?: boolean | undefined;
timezones?: Array<Timezone> | undefined; // if this is skipped, then it will show the default timezones in the order of UTC, EST, PST, IST, ACT
}): string {
const date: string | Date = data.date;
const onlyShowDate: boolean | undefined = data.onlyShowDate;
const timezones: Array<Timezone> | undefined = data.timezones;

View File

@@ -294,7 +294,7 @@ export class Service extends DatabaseService<Model> {
_id: true,
email: true,
name: true,
timezone: true
timezone: true,
},
},
props: {

View File

@@ -228,7 +228,7 @@ export class Service extends DatabaseService<Model> {
_id: true,
email: true,
name: true,
timezone: true
timezone: true,
},
},