Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(worker): timed digest event merging #4979

Merged

Conversation

scopsy
Copy link
Contributor

@scopsy scopsy commented Dec 12, 2023

What change does this PR introduce?

Why was this change needed?

NV-3288

Other information (Screenshots)

Copy link

linear bot commented Dec 12, 2023

@scopsy scopsy marked this pull request as ready for review December 13, 2023 07:35

const promiseTimeout = (ms: number): Promise<void> => new Promise((resolve) => setTimeout(resolve, ms));

describe('Trigger event - Scheduled Digest Mode - /v1/events/trigger (POST)', function () {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a new test suite for scheduled digest

@@ -215,7 +216,7 @@ export class JobRepository extends BaseRepository<JobDBModel, JobEntity, Enforce
_subscriberId: this.convertStringToObjectId(job._subscriberId),
...(digestKey && { [`payload.${digestKey}`]: digestValue }),
},
'_id'
'_id _notificationId'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We removed the digest filter steps, and in order to replace it's functionality of updating the notificationId after the active digest, we return it here to later update the entity.

}
}
},
runDelayedImmediatly: async () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new testing functionality allows running immediatly delayed jobs on bull mq

$set: {
status: JobStatusEnum.MERGED,
_mergedDigestId: activeDigestId,
await Promise.all([
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored to use promise all to improve performance

public async execute(
command: DigestFilterStepsCommand
): Promise<NotificationStepEntity[]> {
const action: DigestFilterStepsRegular | DigestFilterStepsTimed =
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code is not needed anymore, since we want to only make a single decision on digest merged or not in the digest add job phase. Instead of doing it multiple times.

@scopsy scopsy changed the title fix: timed digest event merging fix(worker): timed digest event merging Dec 13, 2023
Copy link
Contributor

@davidsoderberg davidsoderberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍

@LetItRock LetItRock force-pushed the nv-3288-digest-events-are-not-aggregated-in-scheduled-digest branch from fab9752 to 882f781 Compare December 13, 2023 08:59
@LetItRock LetItRock merged commit 87d7059 into next Dec 13, 2023
26 checks passed
@LetItRock LetItRock deleted the nv-3288-digest-events-are-not-aggregated-in-scheduled-digest branch December 13, 2023 10:31
LetItRock added a commit that referenced this pull request Dec 13, 2023
* fix: timed digest event gathering

* feat: remove un needed digest filtering steps

* fix: spelling

* fix: object id typing

* fix: increase timeout

* chore(api): remove mocha timeout on package.json scripts

---------

Co-authored-by: Paweł <pawel.tymczuk@gmail.com>
LetItRock added a commit that referenced this pull request Dec 13, 2023
* fix: timed digest event gathering

* feat: remove un needed digest filtering steps

* fix: spelling

* fix: object id typing

* fix: increase timeout

* chore(api): remove mocha timeout on package.json scripts

---------

Co-authored-by: Paweł <pawel.tymczuk@gmail.com>
LetItRock added a commit that referenced this pull request Dec 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants