Skip to content

Instantly share code, notes, and snippets.

@theeye-io
Created March 4, 2018 15:09
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 theeye-io/658f80ca64c110088f9dfd0d98a628f5 to your computer and use it in GitHub Desktop.
Save theeye-io/658f80ca64c110088f9dfd0d98a628f5 to your computer and use it in GitHub Desktop.
This scripts calculates the total worked hours by Ticker user for a given date.
#!/bin/bash
token="YourToken"
user="YourUser"
id="YourID"
startsDay="2018-02-01"
endsDay="2018-02-28"
users=$(curl -s -H "Authorization: Token token=$token" \
-H "User-Agent: Theeye ($user)" \
https://www.tickspot.com/$id/api/v2/users|jq '.[]| "\(.id) \(.email)"')
for interactano in ${users//" "/"|"}
do
interactanoID=$(echo $interactano|cut -d'|' -f1|sed s/\"//g)
interactarnoMail=$(echo $interactano|cut -d'|' -f2|sed s/\"//g)
HoursPerInteractano=$(curl -s -H "Authorization: Token token=$token" \
-H "User-Agent: Theeye ($user)" \
"https://www.tickspot.com/$id/api/v2/entries.json?user_id=$interactanoID&start_date=$startsDay&end_date=$endsDay" | jq '.[].hours')
totalHoursPerInteractano=$(echo $HoursPerInteractano|sed 's/\n//g'|sed -e 's/[[:space:]]/\+/g'|bc)
echo "user $interactarnoMail, $totalHoursPerInteractano"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment