DEV Community

Ben Halpern for The DEV Team

Posted on

Call for Contributions: Move DelayedJob Calls to ActiveJob

Hey folks, we've been working on a gradual migration from DelayedJob to ActiveJob within the DEV codebase.

Move delay calls to ActiveJob #3136

As described in #2497, to be less dependent of DelayedJob we also need to move jobs which are created by calling delay method to ActiveJob:

Here is the list of the calls:

  • [x] Slackbot.ping
  • [x] reaction.create
  • [x] ArticleAnalyticsFetcher.new.update_analytics
  • [x] HtmlVariantSuccess.create
  • [x] HtmlVariantTrial.create
  • [x] message.send_push
  • [x] RssReader.new.fetch_user
  • [x] several calls in trigger_delayed_index
  • [x] index.delay.delete_object("users-#{id}")
  • [x] user.follow
  • [x] chat_channel.delay.index! - https://github.com/thepracticaldev/dev.to/pull/4317

Actions for each of the calls:

  • create a corresponding ActiveJob, specify a queue name
  • call the required method inside a job
  • replace the delay method calls with a job perform_later call
  • you may need to modify the existing tests by using perform_enqueued_job instead of run_background_jobs_immediately helper

Remember to pass record ids (if needed) instead of ActiveRecord objects to a job to avoid deserialization errors (#1621)

Take a look at the issue. We have a lot of merged pull requests to use as a guideline to get you started, for example...

Moved send_mention_notification to ActiveJob #3566

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

  • [x] Refactor

Description

  • moved send_mention_notification to ActiveJob
  • used @copasetickid's pr and refined it

Related Tickets & Documents

#1996

Happy coding!

Top comments (2)

Collapse
 
techbos profile image
TechBos😎

If you are like me who is new to Ruby on Rails (RoR) and are unsure what is ActiveJob vs DelayedJob:

  • DelayedJob is one of the background job systems in RoR. There are also other job systems such as Resque or Sidekiq.
  • ActiveJob is a wrapper on top of DelayedJob. It's an abstraction layer that gives you freedom to switch the underlying job system implementation. E.g., you can use ActiveJob with DelayedJob and later switch to Resque without having to rewrite job code.

Read more:

Collapse
 
lightalloy profile image
Anna Buianova

Actually, the linked "Moved send_mention_notification to ActiveJob" is even a bit more complex comparing to the remaining tasks.
For the more similar ones, you can look at the pull requests connected to the issue, like this one:

Move HtmlVariantTrial.create delay calls to ActiveJob (#3173) #3239

cyrillefr avatar
cyrillefr commented on Jun 19, 2019
- add AJ job + job spec
- refactor call

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

  • [x] Refactor
  • [ ] Feature
  • [ ] Bug Fix
  • [ ] Documentation Update

Description

Move HtmlVariantTrial.create delay calls to ActiveJob

Related Tickets & Documents

#3136

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

Added to documentation?

  • [ ] docs.dev.to
  • [ ] readme
  • [x] no documentation needed

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

alt_text