Module: Housekeeping::Timestamps

Extended by:
ActiveSupport::Concern
Included in:
AlternateValue, 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



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/housekeeping/timestamps.rb', line 52

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