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/avoid hazards when upserting job schedulers #2892

Merged
merged 7 commits into from
Nov 11, 2024

Conversation

manast
Copy link
Contributor

@manast manast commented Nov 10, 2024

Fixes #2876

@roggervalf roggervalf force-pushed the fix/avoid-hazards-when-upserting-job-schedulers branch from 9d086ee to 937b8f8 Compare November 10, 2024 22:32
@manast manast requested review from roggervalf and fgozdz November 11, 2024 11:36
Copy link
Collaborator

@roggervalf roggervalf left a comment

Choose a reason for hiding this comment

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

Lgtm, added some non-blocker comments

@@ -268,3 +295,13 @@ export const defaultRepeatStrategy = (
// Ignore error
}
};

function removeUndefinedFields(obj: Record<string, any>) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a duplicated method. It's added in utils but it was not removed from here

@@ -464,11 +465,11 @@ export class Job<
* @returns
*/
asJSON(): JobJson {
return {
return removeUndefinedFields<JobJson>({
Copy link
Collaborator

Choose a reason for hiding this comment

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

ok I get the intention, what if instead of iteration yo all these option at the end, do something like

const jobJson = {
id: this id,
// all the other attributes that don't be unfefined
};

if(this parent) {
jobJson.parent = this.parent;
}
// same idea with the other atrributes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because it is easier to forget and it will be more code to maintain. I discovered that we have a lot of empty fields which just consume space for no reason before I added this feature.

@manast manast merged commit 022f7b7 into master Nov 11, 2024
12 checks passed
@manast manast deleted the fix/avoid-hazards-when-upserting-job-schedulers branch November 11, 2024 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Duplicate job scheduler tasks
2 participants