Skip to content

Commit

Permalink
Fixes #38086 - Slow product last sync audit lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
sjha4 committed Jan 29, 2025
1 parent 06452b5 commit b30acf9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
13 changes: 12 additions & 1 deletion app/models/katello/glue/pulp/repos.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,18 @@ def sync_summary
end

def last_sync_audit
Audited::Audit.where(:auditable_id => self.repositories, :auditable_type => Katello::Repository.name, :action => "sync").order(:created_at).last
repository_ids = self.repositories.pluck(:id)
return nil if repository_ids.blank?

Audited::Audit
.where(
auditable_id: repository_ids,
auditable_type: Katello::Repository.name,
action: "sync"
)
.order(created_at: :desc)
.limit(1)
.first
end

def last_sync
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,9 +396,12 @@ <h4 translate>Sync Status</h4>
<span ng-include="'products/details/partials/sync-status.html'"></span>

<dt translate>Last Sync</dt>
<dd ng-show="repository.last_sync == null" translate>
<dd ng-show="repository.last_sync == null && repository.last_sync_words == null" translate>
Not Synced
</dd>
<dd ng-show="repository.last_sync == null && repository.last_sync_words" translate>
Completed {{ repository.last_sync_words }} ago
</dd>
<dd ng-hide="repository.last_sync == null || repository.last_sync.ended_at == null">
<relative-date date="repository.last_sync.ended_at" />
(<short-date-time date="repository.last_sync.ended_at" /> <translate>Local Time</translate>)
Expand Down

0 comments on commit b30acf9

Please sign in to comment.