diff --git a/CHANGELOG.md b/CHANGELOG.md index 702ebf791..d095160c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ - Fix a bug: in invoice configuration panel, VAT amount and total excl. taxes are inverted - Fix a bug: unable to compute user's age when they were born on february 29th and current year is not a leap year - Fix a bug: wrong statistics about hours available for machines reservation. Fix requires user action (1) +- Fix a bug: when regenerating statistics, previous values are not fully removed (only 10 firsts), resulting in wrong statistics generation - [TODO DEPLOY] remove possible value `application/` in `ALLOWED_MIME_TYPES` list, in environment variable - [TODO DEPLOY] `rails runner StatisticCustomAggregation.destroy_all`, then `rake db:seed`, then `rake fablab:es_build_availabilities_index` (1) diff --git a/app/services/statistic_service.rb b/app/services/statistic_service.rb index b824e370e..f19736ee6 100644 --- a/app/services/statistic_service.rb +++ b/app/services/statistic_service.rb @@ -297,8 +297,10 @@ class StatisticService end def clean_stat(options = default_options) + client = Elasticsearch::Model.client %w{Account Event Machine Project Subscription Training User}.each do |o| - "Stats::#{o}".constantize.search(query: {match: {date: format_date(options[:start_date])}}).results.each(&:destroy) + model = "Stats::#{o}".constantize + client.delete_by_query(index: model.index_name, type: model.document_type, body: {query: {match: {date: format_date(options[:start_date])}}}) end end