Skip to content

Instantly share code, notes, and snippets.

@devtdeng
Created February 3, 2015 09:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devtdeng/18cc99467c02ff3c28e8 to your computer and use it in GitHub Desktop.
Save devtdeng/18cc99467c02ff3c28e8 to your computer and use it in GitHub Desktop.
group_tickets
# group tickets to users
group_tickets = (msg, results) ->
if results.count <= 0
return
assigned_tickets = {}
unassinged = 0
for result in results
if result.assignee_id?
assignee_id = result.assignee_id
if "#{assignee_id}" of assigned_tickets
assigned_tickets["#{assignee_id}"] += 1
else
assigned_tickets["#{assignee_id}"] = 1
else
unassinged += 1
# key: user_id, value: tickets number
# TODO, send ticket number and link to chat
msg.send "unassigned: #{unassinged} tickets"
for key, value of assigned_tickets
console.log "key = #{key}, value = #{value} in assigned_tickets"
zendesk_user msg, key, (user_json) ->
name = user_json.user.name
value = assigned_tickets[user_json.user.id]
msg.send "#{name}: #{value} tickets"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment