-
Notifications
You must be signed in to change notification settings - Fork 81
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
Add optional overwrite parameter to CreateJob
and CreateJobs
#916
Changes from 3 commits
7956e80
d1517bf
b865b8a
7f04ed1
13e1c4e
69d5240
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -402,6 +402,8 @@ void BedrockJobsCommand::process(SQLite& db) { | |
// - jobPriority - High priorities go first (optional, default 500) | ||
// - unique - if true, it will check that no other job with this name already exists, if it does it will | ||
// return that jobID | ||
// - overwrite - if true, and unique is true, it will overwrite the existing job with the new jobs data | ||
// (optional, default: true) | ||
// - parentJobID - The ID of the parent job (optional) | ||
// - retryAfter - Amount of auto-retries before marking job as failed (optional) | ||
// | ||
|
@@ -421,6 +423,8 @@ void BedrockJobsCommand::process(SQLite& db) { | |
// - jobPriority - High priorities go first (optional, default 500) | ||
// - unique - if true, it will check that no other job with this name already exists, if it does it will | ||
// return that jobID | ||
// - overwrite - if true, and unique is true, it will overwrite the existing job with the new jobs data | ||
// (optional, default: true) | ||
// - parentJobID - The ID of the parent job (optional) | ||
// - retryAfter - Amount of auto-retries before marking job as failed (optional) | ||
// | ||
|
@@ -566,14 +570,16 @@ void BedrockJobsCommand::process(SQLite& db) { | |
|
||
// Are we creating a new job, or updating an existing job? | ||
if (updateJobID) { | ||
// Update the existing job. | ||
if(!db.writeIdempotent("UPDATE jobs SET " | ||
"repeat = " + SQ(SToUpper(job["repeat"])) + ", " + | ||
"data = JSON_PATCH(data, " + safeData + "), " + | ||
"priority = " + SQ(priority) + " " + | ||
"WHERE jobID = " + SQ(updateJobID) + ";")) | ||
{ | ||
STHROW("502 update query failed"); | ||
if (!SContains(job, "overwrite") || job["overwrite"] == "true") { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you also want to check if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not quite following. What would we check if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Damn sorry, I mean is equal to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah good catch, will add that |
||
// Update the existing job. | ||
if(!db.writeIdempotent("UPDATE jobs SET " | ||
"repeat = " + SQ(SToUpper(job["repeat"])) + ", " + | ||
"data = JSON_PATCH(data, " + safeData + "), " + | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmmm you sure about PATCH? Don't we want to replace the whole data? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the same query as before, just indented. I agree it probably should not be a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh... 🤦 you are right |
||
"priority = " + SQ(priority) + " " + | ||
"WHERE jobID = " + SQ(updateJobID) + ";")) | ||
{ | ||
STHROW("502 update query failed"); | ||
} | ||
} | ||
|
||
// If we are calling CreateJob, return early, there are no more jobs to create. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.