Sha256: af09e5b6e0fa335496897b18f29ae9c9cd75408c38c1b739a770eeecfe4814ad

Contents?: true

Size: 1006 Bytes

Versions: 28

Compression:

Stored size: 1006 Bytes

Contents

module Workarea
  class GenerateInsights
    include Sidekiq::Worker
    delegate :perform, to: :class

    class << self
      def generate_all!
        generate_daily_insights
        generate_weekly_insights
        generate_monthly_insights
      end

      def perform(*)
        generate_daily_insights
        generate_weekly_insights if Time.current.monday?
        generate_monthly_insights if Time.current.day == 1
      end

      def generate_daily_insights
        Insights::Base.subclasses.each(&:generate_daily!)
      end

      def generate_weekly_insights
        Metrics::ProductForLastWeek.aggregate!
        Metrics::ProductByWeek.append_last_week!
        Metrics::SearchForLastWeek.aggregate!
        Metrics::SearchByWeek.append_last_week!
        Metrics::UpdateUserAggregations.update!
        Insights::Base.subclasses.each(&:generate_weekly!)
      end

      def generate_monthly_insights
        Insights::Base.subclasses.each(&:generate_monthly!)
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

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