Last active
November 6, 2022 02:28
-
-
Save myselfhimself/31b79e4d403aedf54842ed6036fdb70e to your computer and use it in GitHub Desktop.
Timesheet help from one's Github activity using Github CLI's `gh` and the `gh-user-activity` extension's code
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
# This is an even more modified version of: https://github.com/aquilax/gh-user-activity/pull/1 with day of week echo'ing | |
#!/usr/bin/env bash | |
set -e | |
GH_PAGES=${2:-1} | |
GH_USER=$1 | |
if [[ -z "$GH_USER" ]]; then | |
if ! GH_USER=$(gh api user --template="{{- print .login -}}"); then | |
echo "${GH_USER}" | |
exit 1 | |
fi | |
fi | |
# shellcheck disable=SC2016 | |
TEMPLATE=' | |
{{- range $event := . -}} | |
{{- printf "%s %s\n" $event.created_at $event.repo.name -}} | |
{{- end -}} | |
' | |
for a in $(eval echo "{1..$GH_PAGES}") | |
do | |
GH_LINE=$(gh api -H 'accept: application/vnd.github.v3+json' "users/$GH_USER/events?per_page=100&page=$a" --template="${TEMPLATE}") | |
DOW=$(echo "$GH_LINE" | awk '{ print $1 }' | xargs -IAA date -d "AA" +'%A') | |
paste <(echo "$DOW" | xargs printf "%.20s\n") - - <(echo "$GH_LINE") < /dev/null | |
done |
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
# ./project_reporting.bash | |
# Thanks to this you know which weekdays you worked on which repository.. and can invoice with exactness | |
4 monday 2022-10-10 nnnnn-org/nnnproject | |
5 tuesday 2022-10-11 nnnnn-org/nnnproject | |
1 tuesday 2022-10-11 jawira/doctrine-diagram-bundle | |
6 tuesday 2022-10-11 nnnnn-org/nnnproject | |
2 wednesday 2022-10-12 nnnnn-org/nnnproject | |
1 wednesday 2022-10-12 jawira/doctrine-diagram-bundle | |
2 wednesday 2022-10-12 nnnnn-org/nnnproject | |
3 thursday 2022-10-13 nnnnn-org/nnnproject | |
9 thursday 2022-10-13 nnnnn-org/mmmproject | |
4 friday 2022-10-14 nnnnn-org/mmmproject | |
3 friday 2022-10-14 symfony-cli/symfony-cli | |
1 friday 2022-10-14 nnnnn-org/mmmproject | |
1 monday 2022-10-17 nnnnn-org/mmmproject | |
1 monday 2022-10-17 symfony/symfony-docs | |
1 monday 2022-10-17 nnnnn-org/mmmproject | |
1 tuesday 2022-10-18 symfony-cli/symfony-cli | |
1 tuesday 2022-10-18 nnnnn-org/mmmproject | |
1 tuesday 2022-10-18 zenstruck/mailer-test | |
7 tuesday 2022-10-18 nnnnn-org/mmmproject | |
1 tuesday 2022-10-18 slope-it/clock-mock | |
17 tuesday 2022-10-18 nnnnn-org/mmmproject | |
1 wednesday 2022-10-19 nnnnn-org/mmmproject | |
1 wednesday 2022-10-19 symfony-cli/symfony-cli | |
4 wednesday 2022-10-19 nnnnn-org/mmmproject | |
10 thursday 2022-10-20 nnnnn-org/mmmproject | |
9 friday 2022-10-21 nnnnn-org/mmmproject | |
1 friday 2022-10-21 pbeshai/p5js-ccapture | |
1 friday 2022-10-21 jdeboi/p5.mapper | |
4 saturday 2022-10-22 nnnnn-org/mmmproject | |
1 saturday 2022-10-22 tw3lveparsecs/github-actions-set-variables | |
4 saturday 2022-10-22 nnnnn-org/mmmproject | |
1 saturday 2022-10-22 dunglas/symfony-docker |
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
#!/bin/bash | |
# you may skip the project1 and project2 sed commands, they allow to join same-prefixed repository names into a same one | |
bash gh-user-activity myselfhimself 3 | sed 's/T.*Z//' | sed 's/project1-.*/project1/' | sed 's/project2-.*/project2/' | uniq -c | tac | less |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment