-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Worker/estimate default language #5697
Worker/estimate default language #5697
Conversation
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.
Thanks for another PR!!! Great start but there are a few additional pieces this needs to get it ready to go.
class EstimateDefaultLanguageWorker | ||
include Sidekiq::Worker | ||
|
||
sidekiq_options queue: :high_priority, retry: 10 | ||
|
||
def perform(user_id, service = Users::EstimateDefaultLanguage) |
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.
Since we are not using a different service here I think we can remove this argument and explicitly call this service below in the worker.
Users::EstimateDefaultLanguage.call(user) if user
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.
ok, I will change it
@@ -1,6 +1,8 @@ | |||
module Users | |||
class EstimateDefaultLanguageJob < ApplicationJob | |||
queue_as :users_estimate_language | |||
class EstimateDefaultLanguageWorker |
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.
Changing this job to a worker is great but you also need to update the call we make to use the new worker in the user model.
def estimate_default_language
Users::EstimateDefaultLanguageWorker.perform_async(id)
end
Further, you will notice that this method is called in an after_create
callback. At that point, the user is not committed to the database so the worker will not be able to find it. For this reason, we need to change the callback to after_create_commit
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.
got it, I will do it
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.
Hi @maykonmenezes, thanks for the changes!
There are two failed specs: https://travis-ci.com/thepracticaldev/dev.to/builds/146065261
I think we should also lean on the safe side here and keep the old job in the code with this PR, less work for the SRE team that doesn't have to manually empty the queue.
Thank you again :)
2f78858
to
5212434
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.
Hi @maykonmenezes, the two specs are still failing: https://travis-ci.com/thepracticaldev/dev.to/builds/146298922
ps. unless for integrating changes needed in a branch or to fix merge conflicts, in the contributing guide we encourage people not to force push after the initial reviews :)
Hey @maykonmenezes - thank you so much for your help on this! We're in the home stretch of completing the epic (#5305). Did you want to go ahead and implement the changes discussed above? |
Hey @maykonmenezes! I didn't hear back so I went ahead and pushed up the changes since we're in the final stretch of the epic (#5305). Thanks again for getting the ball rolling on this - it was a huge help! |
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 🚀
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.
Thank you @atsmith813 and thanks again @maykonmenezes for kickstarting all of this!
I'm looking at this job and can't help but think about the |
I'm not sure I understood correctly your note but I think these classes are doing two different things (the naming could be improved):
There's a lot to be done for i10n in the app but I'm not sure these two classes could be merged |
What type of PR is this? (check all applicable)
Description
Moving estimate default language job to sideqik
Related Tickets & Documents
#5305
Mobile & Desktop Screenshots/Recordings (if there are UI changes)
Added to documentation?
[optional] What gif best describes this PR or how it makes you feel?