Skip to content

Commit

Permalink
Fixes #31318 - Never synced products show synced date (Katello#10994)
Browse files Browse the repository at this point in the history
  • Loading branch information
sjha4 authored May 15, 2024
1 parent 48746af commit 19d4dd7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions app/models/katello/glue/pulp/repos.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,22 @@ def sync_summary
end

def last_sync_audit
Audited::Audit.where(:auditable_id => self.repositories, :auditable_type => Katello::Repository.name).order(:created_at).last
Audited::Audit.where(:auditable_id => self.repositories, :auditable_type => Katello::Repository.name, :action => "sync").order(:created_at).last
end

def last_sync
last_repo_sync_task&.started_at&.to_s || last_sync_audit&.created_at&.to_s
end

def last_repo_sync_task
@last_sync_task ||= last_repo_sync_tasks.first
@last_sync_task ||= last_repo_sync_tasks&.first
end

def last_repo_sync_tasks
ids = repos(self.library, nil, false).pluck(:id).join(',')
label = ::Actions::Katello::Repository::Sync.name
type = ::Katello::Repository.name
return nil if ids.empty?
ForemanTasks::Task.search_for("label = #{label} and resource_type = #{type} and resource_id ^ (#{ids})")
.order("started_at desc")
end
Expand Down

0 comments on commit 19d4dd7

Please sign in to comment.