Sha256: 2ee05e9f3f1bcd0b367904182158ccc4528794c7db47681b935306e603fcf42f

Contents?: true

Size: 1.2 KB

Versions: 81

Compression:

Stored size: 1.2 KB

Contents

class Avo::Cards::<%= class_name.camelize %> < Avo::Cards::MetricCard
  self.id = "<%= name.underscore %>"
  self.label = "<%= name.underscore.humanize %>"
  # self.description = "Some description"
  # self.cols = 1
  # self.initial_range = 30
  # self.ranges = {
  #   "7 days": 7,
  #   "30 days": 30,
  #   "60 days": 60,
  #   "365 days": 365,
  #   Today: "TODAY",
  #   "Month to date": "MTD",
  #   "Quarter to date": "QTD",
  #   "Year to date": "YTD",
  #   All: "ALL",
  # }
  # self.prefix = ""
  # self.suffix = ""

  def query
    # from = Date.today.midnight - 1.week
    # to = DateTime.current

    # if range.present?
    #   if range.to_s == range.to_i.to_s
    #     from = DateTime.current - range.to_i.days
    #   else
    #     case range
    #     when "TODAY"
    #       from = DateTime.current.beginning_of_day
    #     when "MTD"
    #       from = DateTime.current.beginning_of_month
    #     when "QTD"
    #       from = DateTime.current.beginning_of_quarter
    #     when "YTD"
    #       from = DateTime.current.beginning_of_year
    #     when "ALL"
    #       from = Time.at(0)
    #     end
    #   end
    # end

    # result User.where(created_at: from..to).count

    result 101
  end
end

Version data entries

81 entries across 81 versions & 1 rubygems

Version Path
avo-3.14.3 lib/generators/avo/templates/cards/metric_card_sample.tt
avo-3.14.2 lib/generators/avo/templates/cards/metric_card_sample.tt
avo-3.14.1 lib/generators/avo/templates/cards/metric_card_sample.tt
avo-3.14.0 lib/generators/avo/templates/cards/metric_card_sample.tt
avo-3.13.7 lib/generators/avo/templates/cards/metric_card_sample.tt
avo-3.13.6 lib/generators/avo/templates/cards/metric_card_sample.tt
avo-3.13.5 lib/generators/avo/templates/cards/metric_card_sample.tt
avo-3.13.4 lib/generators/avo/templates/cards/metric_card_sample.tt
avo-3.13.3 lib/generators/avo/templates/cards/metric_card_sample.tt
avo-3.13.2 lib/generators/avo/templates/cards/metric_card_sample.tt
avo-3.13.1 lib/generators/avo/templates/cards/metric_card_sample.tt
avo-3.13.0 lib/generators/avo/templates/cards/metric_card_sample.tt
avo-3.12.0 lib/generators/avo/templates/cards/metric_card_sample.tt
avo-3.11.10 lib/generators/avo/templates/cards/metric_card_sample.tt
avo-3.11.9 lib/generators/avo/templates/cards/metric_card_sample.tt
avo-3.11.8 lib/generators/avo/templates/cards/metric_card_sample.tt
avo-3.11.7 lib/generators/avo/templates/cards/metric_card_sample.tt
avo-3.11.6 lib/generators/avo/templates/cards/metric_card_sample.tt
avo-3.11.5 lib/generators/avo/templates/cards/metric_card_sample.tt
avo-3.11.4 lib/generators/avo/templates/cards/metric_card_sample.tt