Skip to content

Commit

Permalink
Revert "[PR] Fixes #37109 - allow to use eager loading on latest_vers…
Browse files Browse the repository at this point in the history
…ion_object"

This reverts commit 59c256b.
  • Loading branch information
sbernhard committed Feb 15, 2024
1 parent 3626099 commit d7d0a72
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 4 additions & 1 deletion app/models/katello/content_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class ContentView < Katello::Model

has_many :content_view_versions, :class_name => "Katello::ContentViewVersion", :dependent => :destroy
alias_method :versions, :content_view_versions
has_one :latest_version_object, -> { latest }, :class_name => "Katello::ContentViewVersion"
# Note the difference between content_view_components and component_composites both refer to
# ContentViewComponent but mean different things.
# content_view_components -> Topdown, given I am a composite CV get the associated components belonging to me
Expand Down Expand Up @@ -342,6 +341,10 @@ def latest_version_env
latest_version_object.try(:environments) || []
end

def latest_version_object
self.versions.order('major DESC').order('minor DESC').first
end

def last_task
last_task_id = history.order(:created_at)&.last&.task_id
last_task_id ? ForemanTasks::Task.find_by(id: last_task_id) : nil
Expand Down
2 changes: 0 additions & 2 deletions app/models/katello/content_view_version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ class ContentViewVersion < Katello::Model
joins(:repositories).includes(:content_view).merge(repositories).distinct
end

scope :latest, -> { order('major DESC').order('minor DESC') }

scoped_search :on => :content_view_id, :only_explicit => true, :validator => ScopedSearch::Validators::INTEGER
scoped_search :on => :major, :rename => :version, :complete_value => true, :ext_method => :find_by_version
serialize :content_counts
Expand Down

0 comments on commit d7d0a72

Please sign in to comment.