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

Worker/estimate default language #5697

Merged

Conversation

maykonmenezes
Copy link
Contributor

What type of PR is this? (check all applicable)

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

Moving estimate default language job to sideqik

Related Tickets & Documents

#5305

Mobile & Desktop Screenshots/Recordings (if there are UI changes)

Added to documentation?

  • docs.dev.to
  • readme
  • no documentation needed

[optional] What gif best describes this PR or how it makes you feel?

alt_text

@maykonmenezes maykonmenezes requested a review from a team January 24, 2020 11:59
@pr-triage pr-triage bot added the PR: unreviewed bot applied label for PR's with no review label Jan 24, 2020
Copy link
Contributor

@mstruve mstruve left a 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)
Copy link
Contributor

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

Copy link
Contributor Author

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
Copy link
Contributor

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

Copy link
Contributor Author

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

@pr-triage pr-triage bot added PR: reviewed-changes-requested bot applied label for PR's where reviewer requests changes PR: unreviewed bot applied label for PR's with no review and removed PR: unreviewed bot applied label for PR's with no review PR: reviewed-changes-requested bot applied label for PR's where reviewer requests changes labels Jan 24, 2020
Copy link
Contributor

@rhymes rhymes left a 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 :)

@pr-triage pr-triage bot added PR: reviewed-changes-requested bot applied label for PR's where reviewer requests changes and removed PR: unreviewed bot applied label for PR's with no review labels Jan 26, 2020
@maykonmenezes maykonmenezes force-pushed the worker/estimate-default-language branch from 2f78858 to 5212434 Compare January 27, 2020 21:25
@pr-triage pr-triage bot added PR: unreviewed bot applied label for PR's with no review and removed PR: reviewed-changes-requested bot applied label for PR's where reviewer requests changes labels Jan 27, 2020
Copy link
Contributor

@rhymes rhymes left a 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 :)

@pr-triage pr-triage bot added PR: reviewed-changes-requested bot applied label for PR's where reviewer requests changes and removed PR: unreviewed bot applied label for PR's with no review labels Jan 28, 2020
@atsmith813
Copy link
Contributor

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?

@pr-triage pr-triage bot added PR: unreviewed bot applied label for PR's with no review and removed PR: reviewed-changes-requested bot applied label for PR's where reviewer requests changes labels Feb 6, 2020
@atsmith813
Copy link
Contributor

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!

Copy link
Contributor

@mstruve mstruve left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

@pr-triage pr-triage bot added PR: reviewed-approved bot applied label for PR's where reviewer approves changes and removed PR: unreviewed bot applied label for PR's with no review labels Feb 6, 2020
Copy link
Contributor

@rhymes rhymes left a 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!

@mstruve mstruve merged commit 58b96f1 into forem:master Feb 7, 2020
@pr-triage pr-triage bot added PR: merged bot applied label for PR's that are merged and removed PR: reviewed-approved bot applied label for PR's where reviewer approves changes labels Feb 7, 2020
@mstruve
Copy link
Contributor

mstruve commented Feb 7, 2020

I'm looking at this job and can't help but think about the LanguageDetector class in /labor that we use to detect article language. Feels like we should be detecting it the same way everywhere. @rhymes any thoughts on that? Should we make an #issue for it?

@rhymes
Copy link
Contributor

rhymes commented Feb 10, 2020

I'm not sure I understood correctly your note but I think these classes are doing two different things (the naming could be improved):

  • app/labor/language_detector.rb uses cld to infer language an article is written in

  • app/services/users/estimate_default_language.rb uses a combination of settings and the user's twitter identity to guess which default language they would prefer reading in

There's a lot to be done for i10n in the app but I'm not sure these two classes could be merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: merged bot applied label for PR's that are merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants