Skip to content

Commit

Permalink
chore(utils): rename from Time to TimeMs
Browse files Browse the repository at this point in the history
  • Loading branch information
e11sy committed Feb 5, 2025
1 parent e83bfe6 commit c4b59de
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
12 changes: 6 additions & 6 deletions lib/utils/time.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
/**
* Time intervals in ms
*/
export default class Time {
export default class TimeMs {
/** The smallest time interval */
public static MILLISECOND = 1;

public static SECOND = Time.MILLISECOND * 1000;
public static SECOND = TimeMs.MILLISECOND * 1000;

public static MINUTE = Time.SECOND * 60;
public static MINUTE = TimeMs.SECOND * 60;

public static HOUR = Time.MINUTE * 60;
public static HOUR = TimeMs.MINUTE * 60;

public static DAY = Time.HOUR * 24;
public static DAY = TimeMs.HOUR * 24;

public static WEEK = Time.DAY * 7;
public static WEEK = TimeMs.DAY * 7;
}
6 changes: 3 additions & 3 deletions workers/grouper/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { MS_IN_SEC } from '../../../lib/utils/consts';
import DataFilter from './data-filter';
import RedisHelper from './redisHelper';
import levenshtein from 'js-levenshtein';
import Time from '../../../lib/utils/time';
import TimeMs from '../../../lib/utils/time';

/**
* Error code of MongoDB key duplication error
Expand Down Expand Up @@ -258,10 +258,10 @@ export default class GrouperWorker extends Worker {
.toArray();
},
/**
* Time class stores time intervals in milliseconds, however NodeCache ttl needs to be specified in seconds
* TimeMs class stores time intervals in milliseconds, however NodeCache ttl needs to be specified in seconds
*/
/* eslint-disable-next-line @typescript-eslint/no-magic-numbers */
Time.MINUTE / 1000);
TimeMs.MINUTE / 1000);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions workers/notifier/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { NotifierEvent, NotifierWorkerTask } from '../types/notifier-task';
import { Rule, WhatToReceive } from '../types/rule';
import { SenderWorkerTask } from 'hawk-worker-sender/types/sender-task';
import RuleValidator from './validator';
import Time from '../../../lib/utils/time';
import TimeMs from '../../../lib/utils/time';
import RedisHelper from './redisHelper';

/**
Expand Down Expand Up @@ -114,10 +114,10 @@ export default class NotifierWorker extends Worker {
return this.getProjectNotificationRules(projectId);
},
/**
* Time class stores time intervals in milliseconds, however NodeCache ttl needs to be specified in seconds
* TimeMs class stores time intervals in milliseconds, however NodeCache ttl needs to be specified in seconds
*/
/* eslint-disable-next-line @typescript-eslint/no-magic-numbers */
Time.MINUTE / 1000
TimeMs.MINUTE / 1000
);
} catch (e) {
this.logger.warn('Failed to get project notification rules because ', e);
Expand Down
6 changes: 3 additions & 3 deletions workers/sender/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { DatabaseController } from '../../../lib/db/controller';
import { Worker } from '../../../lib/worker';
import * as pkg from '../package.json';
import './env';
import Time from '../../../lib/utils/time';
import TimeMs from '../../../lib/utils/time';

import { PasswordResetNotification, PaymentSuccessNotification, TemplateEventData, WorkspaceInviteNotification } from '../types/template-variables/';
import NotificationsProvider from './provider';
Expand Down Expand Up @@ -307,7 +307,7 @@ export default abstract class SenderWorker extends Worker {
/**
* Send message not often than once per day
*/
const throttleInterval = Time.DAY;
const throttleInterval = TimeMs.DAY;

const { workspaceId, daysLeft } = task.payload;

Expand Down Expand Up @@ -375,7 +375,7 @@ export default abstract class SenderWorker extends Worker {
/**
* Send message not often than once per day
*/
const throttleInterval = Time.DAY;
const throttleInterval = TimeMs.DAY;

const { workspaceId, eventsCount, eventsLimit } = task.payload;

Expand Down

0 comments on commit c4b59de

Please sign in to comment.