Class: Workarea::Insights::Base

Inherits:
Object
  • Object
show all
Includes:
ApplicationDocument
Defined in:
app/models/workarea/insights/base.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ApplicationDocument

#releasable?

Methods included from Sidekiq::Callbacks

assert_valid_config!, async, disable, enable, inline, #run_callbacks

Methods included from Mongoid::Document

#embedded_children

Class Method Details

.beginning_of_last_monthObject



44
45
46
# File 'app/models/workarea/insights/base.rb', line 44

def beginning_of_last_month
  Time.current.last_month.beginning_of_month
end

.currentObject



35
36
37
# File 'app/models/workarea/insights/base.rb', line 35

def current
  desc(:created_at).first || new
end

.dashboardsObject

Allow subclasses to specify on which dashboards they show



40
41
42
# File 'app/models/workarea/insights/base.rb', line 40

def dashboards
  []
end

.end_of_last_monthObject



48
49
50
# File 'app/models/workarea/insights/base.rb', line 48

def end_of_last_month
  Time.current.last_month.end_of_month
end

.generate_daily!Object



23
24
25
# File 'app/models/workarea/insights/base.rb', line 23

def generate_daily!
  # allow subclasses to implement daily insight generation
end

.generate_monthly!Object



31
32
33
# File 'app/models/workarea/insights/base.rb', line 31

def generate_monthly!
  # allow subclasses to implement monthly insight generation
end

.generate_weekly!Object



27
28
29
# File 'app/models/workarea/insights/base.rb', line 27

def generate_weekly!
  # allow subclasses to implement weekly insight generation
end

Instance Method Details

#include?(test) ⇒ Boolean

Returns:

  • (Boolean)


57
58
59
60
61
62
63
# File 'app/models/workarea/insights/base.rb', line 57

def include?(test)
  test_typecasted = test.transform_keys(&:to_s).transform_values(&:to_s)
  results.any? do |result|
    result_typecasted = result.transform_keys(&:to_s).transform_values(&:to_s)
    (test_typecasted.to_a - result_typecasted.to_a).empty?
  end
end

#slugObject



53
54
55
# File 'app/models/workarea/insights/base.rb', line 53

def slug
  self.class.name.demodulize.underscore
end