class AppsignalReport::WeeklyReport

Weekly Report

Compare metrics of the last week with the one before that:

Public Instance Methods

generate() click to toggle source
# File lib/appsignal_report/weekly_report.rb, line 11
def generate
  @report = {
    title: title,
    now: Time.now.utc,
    one_week_ago: (Time.now - (3600 * 24 * 7)).utc,
    two_weeks_ago: (Time.now - (3600 * 24 * 14)).utc,
  }
  process_metrics
end

Private Instance Methods

info_message() click to toggle source

@return [String]

# File lib/appsignal_report/weekly_report.rb, line 24
def info_message
  week_1 = "#{report[:two_weeks_ago].to_date}-#{report[:one_week_ago].to_date}"
  week_2 = "#{report[:one_week_ago].to_date}-#{report[:now].to_date}"
  "Comparing the weeks #{week_1} and #{week_2}."
end
metrics_uri() click to toggle source

@return [URI]

# File lib/appsignal_report/weekly_report.rb, line 35
def metrics_uri
  query = URI.encode_www_form(
    token: api_token,
    kind: :web,
    from: report[:two_weeks_ago].iso8601,
    'fields[]': %i(mean count ex_rate)
  )
  URI("#{base_uri}/graphs.json?#{query}")
end
report_split_time() click to toggle source
# File lib/appsignal_report/weekly_report.rb, line 30
def report_split_time
  report[:one_week_ago]
end