Skip to content

Commit

Permalink
count documents in database in rake tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Jul 27, 2019
1 parent c66f81d commit 4420fdf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/controllers/clients_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def index
query: params[:query],
"provider-id" => params[:provider_id],
software: params[:software],
"clientTypes" => params[:client_type],
year: params[:year],
"page[number]" => page[:number] + 1,
"page[size]" => page[:size],
Expand Down
4 changes: 2 additions & 2 deletions app/models/concerns/indexable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -405,10 +405,10 @@ def index_stats(options={})
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")
last_id = self.maximum(:id) || 1
database_count = self.all.count

message = "Index #{index_name} has #{index_name_count} documents, " \
"#{alternate_index_name} has #{alternate_index_name_count} documents, last_id is #{last_id}."
"#{alternate_index_name} has #{alternate_index_name_count} documents, database has #{database_count} documents."
return message
end

Expand Down

0 comments on commit 4420fdf

Please sign in to comment.