-
Notifications
You must be signed in to change notification settings - Fork 15
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
Betterment/update job #134
Conversation
Done with Self Review, |
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.
This looks cleaner but I have two issues before the reivew
- The version shouldn't come from the user. It's a invisible implementation that you don't need to worry about when writing the code. All you should know is that if your job is stale the update won't work.
- If tomorrow I add a new field to
Job
and callupdate_job
, it might feel that it would just work but actually I would need to update the logic and handle the if else. Is there a way to catch this silent failure later?
Updated the logic to don't let parent fn to decide whether to update |
8dc3665
to
e5b55c1
Compare
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.
lgtm
* update: JobItemUpdates * update: changelog * update: e2e fixed * update: tests comments removed * update: cleaning print statement * update: version, updated_at will always automatically be updated * update: version based job fetch test case * fix: build * update: simplified impl for update_job * fix: lint * update: false call check handled * test update: panic if job is not found * update: cleaned test case for db update_job * update: shifted to_document to mongodb * update: builder pattern for jobitemupdates * update: default->new * update: lint fix * update: fixed fatal error * update: match statement corrected
This PR solves #112.
update_job_status
,update_metadata
,update_job_optimistically
,post_job_update
functions fromDatabase
implementation.update_job
to useJobItemUpdates
.JobItemUpdates
object with all the needed changes only, which get's reflected on the database.WHY this approach?
update_job
,update_job_status
&update_metadata
to update job values in database.update_job
was being passed with the wholejobItem
to update, in it's usage it was only changing 2-3 values in the job and not the whole job object, resulting in other values unnecessarily being rewritten. (for eg, same version value is being sent within jobItem, resulting in a pointless rewrite 1 -> 1).version
andupdated_at
fields post these updates, since first the version get's rewritten (1->1) and then it's overwritten to an increased value inpost_job_update
(1->2).update_job_status
andupdate_metadata
followed the same trend but only updated individual values.WHAT now ?
update_job
seemed the best approach to move forward with.JobItemUpdates
object that consist of all the updates that needs to be done to the job in a single query.id
andcreated_at
.only_status
andonly_metadata
to allow for cleaner code for these updates.