Skip to content

Instantly share code, notes, and snippets.

@gioiab
Created April 8, 2016 16:56
Show Gist options
  • Save gioiab/9ee169b78ded6f76cdce86a705d1b6d3 to your computer and use it in GitHub Desktop.
Save gioiab/9ee169b78ded6f76cdce86a705d1b6d3 to your computer and use it in GitHub Desktop.
Measurence Engineering Blog - How we send the weekly report to Slack via slack-poster
require 'googlecharts'
class Slack::Report::Weekly < Slack::Report::Base
# prepares a message for the weekly visits
def visits
return no_data if @weekly_report.count == 0
attachment = {
mrkdwn_in: ["text",
"title",
"pretext",
"fields"],
text: "Visits",
image_url: gchart_url([ @weekly_report.weekly_visits_absolute],
nil,
@weekly_report.week_names_for_period)
}
value = description(...)
{
text: %{on the week
#{week_of(@weekly_report.year, @weekly_report.year_week)}
there have been #{value} *visits*
for #{@weekly_report.company.name} @
#{store_name_and_address(@weekly_report.store_reports.first.store)}
},
attachments: [ attachment ]
}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment