From 18e34e86fb3a32945aac9c01b7bc0aaadd3958ed Mon Sep 17 00:00:00 2001 From: Martin Fenner Date: Sat, 27 Jul 2019 13:49:33 +0200 Subject: [PATCH] indicate active index in stats rake task --- app/models/concerns/indexable.rb | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/app/models/concerns/indexable.rb b/app/models/concerns/indexable.rb index 3805dbeb6..2d7221a6b 100644 --- a/app/models/concerns/indexable.rb +++ b/app/models/concerns/indexable.rb @@ -398,17 +398,18 @@ def upgrade_index # show stats for both indexes def index_stats(options={}) - index_name = self.index_name + "_v1" - alternate_index_name = self.index_name + "_v2" + active_index = self.active_index + inactive_index = self.inactive_index client = Elasticsearch::Model.client - stats = client.indices.stats index: [index_name, alternate_index_name], docs: true - index_name_count = stats.dig("indices", index_name, "primaries", "docs", "count") - alternate_index_name_count = stats.dig("indices", alternate_index_name, "primaries", "docs", "count") + stats = client.indices.stats index: [active_index, inactive_index], docs: true + active_index_count = stats.dig("indices", active_index, "primaries", "docs", "count") + inactive_index_count = stats.dig("indices", inactive_index, "primaries", "docs", "count") database_count = self.all.count - message = "Index #{index_name} has #{index_name_count} documents, " \ - "#{alternate_index_name} has #{alternate_index_name_count} documents, database has #{database_count} documents." + message = "Active index #{active_index} has #{active_index_count} documents, " \ + "inactive index #{inactive_index} has #{inactive_index_count} documents, " \ + "database has #{database_count} documents." return message end