Last active
August 31, 2020 08:10
-
-
Save matoous/06c51a6437121a80cd02a0cd7aa6a2ac to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#/bin/sh | |
if [[ -x $GIT_TOKEN ]]; then | |
echo "you need to set GIT_TOKEN env variable" | |
exit 1 | |
fi | |
# Get all merge requests for search-team, we can't use gonuts here because for example SearchAPI is under search team | |
# but we still sometimes work at it. Filter the merge request for only those that have time spent != null. | |
curl https://gitlab.skypicker.com/api/v4/groups/search-team/merge_requests\?state\=all\&per_page\=100 --header "Private-Token: $GIT_TOKEN" -s \ | |
| jq -c ".[] | select(.time_stats.human_total_time_spent != null) | { project_id: .project_id, id: .iid, title: .title }" \ | |
| while read i; do | |
project_id=$(echo $i | jq ".project_id") | |
mr_id=$(echo $i | jq ".id") | |
title=$(echo $i | jq ".title") | |
echo "$title" | |
# Get notes on the MR that were created in last 7 days and filter out only those that added time spent. | |
curl -s https://gitlab.skypicker.com/api/v4/projects/$project_id/merge_requests/$mr_id/notes\?per_page\=100\&created_after\=$(date -v-1w +%Y/%m/%d) --header "Private-Token: $GIT_TOKEN" \ | |
| jq ".[] | select(.body | contains(\"time spent\")) | { time: .body, user: .author.username } | \"\(.user): \(.time)\"" | |
echo "" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment