Skip to content

Instantly share code, notes, and snippets.

@andymeneely
Created October 20, 2015 21:59
Show Gist options
  • Save andymeneely/489ac64f93461add1737 to your computer and use it in GitHub Desktop.
Save andymeneely/489ac64f93461add1737 to your computer and use it in GitHub Desktop.
Slack Punchcard
require 'json'
require 'pp'
# To run this, create a directory called "export" in the current directory.
# Get admin access to Slack
# Get an export of the data.
# This will search export/standup/*.json files
users = {
'U0AB5BETT' => 'andymeneely',
'U0A4X5Z4M' => 'bbesmanoff',
'U0A5UP214' => 'cman131',
'U0A50MDRA' => 'cshapleigh',
'U0A4XEWTB' => 'thenaterhood',
}
def useful?(msg)
return !(msg.key?("subtype")) # don't care about "joined the channel" or other irregular messages
end
by_date = Hash.new {|h,k| h[k] = Array.new }
by_user = Hash.new {|h,k| h[k] = Array.new }
Dir['export/standup/*.json'].each do |file|
JSON.load(File.read(file)).each do |msg|
next unless useful? msg
date = Time.at(msg["ts"].to_f).strftime("%Y-%m-%d")
user = users[msg["user"]]
by_date[date] << user
by_user[user] << date
end
end
puts "PER DATE STATS:"
by_date.each do |date, users|
puts " #{date}: #{users.sort.uniq.join(' ')}"
end
puts "PER USER STATS:"
by_user.each do |user, dates|
puts " #{user}: #{dates.size}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment