module Workarea::Api::Admin::DateIndexes

Public Instance Methods

load() click to toggle source

We do this separately from the DateFiltering module to ensure this happens after a model has defined all of its normal indexes. This prevents the date filtering indexes from applying before explicity defined indexes for models that could include options like a TTL.

# File lib/workarea/api/admin/date_indexes.rb, line 12
def load
  ::Mongoid.models.each do |model|
    if model < ApplicationDocument
      model.index({ updated_at: 1 })
      model.index({ created_at: 1 })
    end
  end
end