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

Move shared BaseExecution concerns into the base class. #1009

Merged
merged 1 commit into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/models/good_job/base_execution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ module GoodJob
# which both read out of the same table.
class BaseExecution < BaseRecord
include ErrorEvents
include Filterable
include Lockable
include Reportable
Comment on lines +8 to +10
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would love if I could group this; include Filterable, Lockable, Reportable
but rubocop is not allowing it :)

Copy link
Owner

Choose a reason for hiding this comment

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

Seems like a standard style; Rails uses it too. My digging surfaced this, but not the best explanation :-)

rubocop/ruby-style-guide#622

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree definitely not worth changing this rule, it just looked nicer in this particular situation to me :)

I think this rule is on by default because of:

  1. Git diffing
  2. Error tracing - line number, if there are multiple mixins on 1 line could be harder to trace


self.table_name = 'good_jobs'

Expand Down
4 changes: 0 additions & 4 deletions app/models/good_job/execution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
module GoodJob
# ActiveRecord model that represents an +ActiveJob+ job.
class Execution < BaseExecution
include Lockable
include Filterable
include Reportable

# Raised if something attempts to execute a previously completed Execution again.
PreviouslyPerformedError = Class.new(StandardError)

Expand Down
4 changes: 0 additions & 4 deletions app/models/good_job/job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ module GoodJob
# A single row from the +good_jobs+ table of executions is fetched to represent a Job.
#
class Job < BaseExecution
include Filterable
include Lockable
include Reportable

# Raised when an inappropriate action is applied to a Job based on its state.
ActionForStateMismatchError = Class.new(StandardError)
# Raised when an action requires GoodJob to be the ActiveJob Queue Adapter but GoodJob is not.
Expand Down