-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
10 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -170,8 +170,6 @@ export default class GrouperWorker extends Worker { | |
throw new DiffCalculationError(e, existedEvent.payload, task.event); | ||
} | ||
|
||
incrementDailyAffectedUsers = incrementDailyAffectedUsers | ||
|
||
const newRepetition = { | ||
groupHash: uniqueEventHash, | ||
payload: diff, | ||
|
@@ -271,6 +269,7 @@ export default class GrouperWorker extends Worker { | |
|
||
// Return early if user is the same as original event | ||
const isUserFromOriginalEvent = existedEvent.payload.user?.id === eventUser.id; | ||
|
||
if (isUserFromOriginalEvent) { | ||
return [false, false]; | ||
} | ||
|
@@ -321,7 +320,7 @@ export default class GrouperWorker extends Worker { | |
} | ||
|
||
/** | ||
* If daily repetition exists, don't increment daily affected users | ||
* If daily repetition exists, don't increment daily affected users | ||
*/ | ||
if (repetitionDaily) { | ||
shouldIncrementDailyAffectedUsers = false; | ||
|
@@ -331,6 +330,7 @@ export default class GrouperWorker extends Worker { | |
* Check Redis lock - if locked, don't increment either counter | ||
*/ | ||
const isLocked = await this.redis.checkOrSetEventLock(existedEvent.groupHash, eventUser.id); | ||
|
||
if (isLocked) { | ||
shouldIncrementRepetitionAffectedUsers = false; | ||
shouldIncrementDailyAffectedUsers = false; | ||
|
@@ -449,6 +449,7 @@ export default class GrouperWorker extends Worker { | |
* @param {string} eventHash - event hash | ||
* @param {string} eventTimestamp - timestamp of the last event | ||
* @param {string|null} repetitionId - event's last repetition id | ||
* @param shouldIncrementAffectedUsers | ||
Check warning on line 452 in workers/grouper/src/index.ts GitHub Actions / ESlint
|
||
* @returns {Promise<void>} | ||
*/ | ||
private async saveDailyEvents( | ||
|
@@ -479,7 +480,10 @@ export default class GrouperWorker extends Worker { | |
lastRepetitionTime: eventTimestamp, | ||
lastRepetitionId: repetitionId, | ||
}, | ||
$inc: { count: 1, affectedUsers: shouldIncrementAffectedUsers ? 1 : 0 } | ||
$inc: { | ||
count: 1, | ||
affectedUsers: shouldIncrementAffectedUsers ? 1 : 0, | ||
}, | ||
}, | ||
{ upsert: true }); | ||
} catch (err) { | ||
|
@@ -489,11 +493,11 @@ export default class GrouperWorker extends Worker { | |
|
||
/** | ||
* Gets the midnight timestamp for the event date or the next day | ||
* | ||
* | ||
* @param eventTimestamp - Unix timestamp of the event | ||
* @param getNext - If true, returns the next day's midnight timestamp | ||
*/ | ||
private getMidnightByEventTimestamp(eventTimestamp: number, getNext: boolean = false): number { | ||
private getMidnightByEventTimestamp(eventTimestamp: number, getNext = false): number { | ||
/** | ||
* Get JavaScript date from event unixtime to convert daily aggregation collection format | ||
* | ||
|