Sha256: 9b29bd4007539215dc5ecb4962217c3a51dd965e91808b760b06f1623cd08bfc

Contents?: true

Size: 1001 Bytes

Versions: 34

Compression:

Stored size: 1001 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::User.update_aggregations!
        Insights::Base.subclasses.each(&:generate_weekly!)
      end

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

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
workarea-core-3.4.45 app/workers/workarea/generate_insights.rb
workarea-core-3.4.44 app/workers/workarea/generate_insights.rb
workarea-core-3.4.43 app/workers/workarea/generate_insights.rb
workarea-core-3.4.42 app/workers/workarea/generate_insights.rb
workarea-core-3.4.41 app/workers/workarea/generate_insights.rb
workarea-core-3.4.40 app/workers/workarea/generate_insights.rb
workarea-core-3.4.39 app/workers/workarea/generate_insights.rb
workarea-core-3.4.38 app/workers/workarea/generate_insights.rb
workarea-core-3.4.37 app/workers/workarea/generate_insights.rb
workarea-core-3.4.36 app/workers/workarea/generate_insights.rb
workarea-core-3.4.35 app/workers/workarea/generate_insights.rb
workarea-core-3.4.34 app/workers/workarea/generate_insights.rb
workarea-core-3.4.33 app/workers/workarea/generate_insights.rb
workarea-core-3.4.32 app/workers/workarea/generate_insights.rb
workarea-core-3.4.31 app/workers/workarea/generate_insights.rb
workarea-core-3.4.30 app/workers/workarea/generate_insights.rb
workarea-core-3.4.29 app/workers/workarea/generate_insights.rb
workarea-core-3.4.28 app/workers/workarea/generate_insights.rb
workarea-core-3.4.27 app/workers/workarea/generate_insights.rb
workarea-core-3.4.26 app/workers/workarea/generate_insights.rb