Sha256: 125f4caa9090e903f077e4213e2b6e2f654812b07c277a8cb8d2fbaab6ce1370

Contents?: true

Size: 747 Bytes

Versions: 28

Compression:

Stored size: 747 Bytes

Contents

module Workarea
  class ProcessSearchRecommendations
    include Sidekiq::Worker

    def perform(*)
      predictor.clean!

      start = Workarea.config.recommendation_expiration.ago

      Metrics::User
        .where(:updated_at.gte => start)
        .desc(:updated_at) # sort by updated_at to ensure use of that index
        .each_by(page_size) { |metrics| add(metrics) }

      predictor.process!
    end

    def predictor
      @predictor ||= Recommendation::SearchPredictor.new
    end

    def add(metrics)
      return unless metrics.viewed.search_ids.many?
      predictor.sessions.add_set(metrics.id, metrics.viewed.search_ids)
    end

    def page_size
      Workarea.config.search_recommendation_index_page_size
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
workarea-core-3.5.27 app/workers/workarea/process_search_recommendations.rb
workarea-core-3.5.26 app/workers/workarea/process_search_recommendations.rb
workarea-core-3.5.25 app/workers/workarea/process_search_recommendations.rb
workarea-core-3.5.23 app/workers/workarea/process_search_recommendations.rb
workarea-core-3.5.22 app/workers/workarea/process_search_recommendations.rb
workarea-core-3.5.21 app/workers/workarea/process_search_recommendations.rb
workarea-core-3.5.20 app/workers/workarea/process_search_recommendations.rb
workarea-core-3.5.19 app/workers/workarea/process_search_recommendations.rb
workarea-core-3.5.18 app/workers/workarea/process_search_recommendations.rb
workarea-core-3.5.17 app/workers/workarea/process_search_recommendations.rb
workarea-core-3.5.16 app/workers/workarea/process_search_recommendations.rb
workarea-core-3.5.15 app/workers/workarea/process_search_recommendations.rb
workarea-core-3.5.14 app/workers/workarea/process_search_recommendations.rb
workarea-core-3.5.13 app/workers/workarea/process_search_recommendations.rb
workarea-core-3.5.12 app/workers/workarea/process_search_recommendations.rb
workarea-core-3.5.11 app/workers/workarea/process_search_recommendations.rb
workarea-core-3.5.10 app/workers/workarea/process_search_recommendations.rb
workarea-core-3.5.9 app/workers/workarea/process_search_recommendations.rb
workarea-core-3.5.8 app/workers/workarea/process_search_recommendations.rb
workarea-core-3.5.7 app/workers/workarea/process_search_recommendations.rb