From b30acf991f0588715cc402ddd9ca1f08e154966a Mon Sep 17 00:00:00 2001 From: Samir Jha Date: Wed, 29 Jan 2025 17:16:08 +0000 Subject: [PATCH] Fixes #38086 - Slow product last sync audit lookup --- app/models/katello/glue/pulp/repos.rb | 13 ++++++++++++- .../repositories/details/views/repository-info.html | 5 ++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/app/models/katello/glue/pulp/repos.rb b/app/models/katello/glue/pulp/repos.rb index 124dbe3ae38..81ef3095162 100644 --- a/app/models/katello/glue/pulp/repos.rb +++ b/app/models/katello/glue/pulp/repos.rb @@ -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 diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/views/repository-info.html b/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/views/repository-info.html index f804ab6a625..99b9636c6cc 100644 --- a/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/views/repository-info.html +++ b/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/views/repository-info.html @@ -396,9 +396,12 @@

Sync Status

Last Sync
-
+
Not Synced
+
+ Completed {{ repository.last_sync_words }} ago +
( Local Time)