Module: Housekeeping::Timestamps

Extended by:
ActiveSupport::Concern
Included in:
GeographicArea, GeographicAreaType, GeographicItem, Language, Namespace, Person, PreparationType, Project, ProjectMember, Repository, Role, Serial, SerialChronology, Source, User
Defined in:
lib/housekeeping/timestamps.rb

Overview

Concern that provides timestamp related methods for housekeeping.

!! https://github.com/ankane/groupdate is now included in TW, and includes many grouping scopes!

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary (collapse)

Instance Method Details

- (Object) data_breakdown_for_chartkick_recent



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/housekeeping/timestamps.rb', line 70

def data_breakdown_for_chartkick_recent
  Rails.application.eager_load!
  data = []
  has_many_relationships.each do |name|

    today      = self.send(name).created_today.count # in_project(self).count
    this_week  = self.send(name).created_this_week.count # in_project(self).count
    this_month = self.send(name).created_in_last(4.weeks).count # in_project(self).count

    if this_month > 0
      data.push({
        name: name.to_s.humanize,
        data: {
          'this week' => this_week,
          today: today,
          'this month' => this_month
        }
      })
    end
  end
  data
end