Created
February 3, 2015 09:39
-
-
Save devtdeng/18cc99467c02ff3c28e8 to your computer and use it in GitHub Desktop.
group_tickets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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