Merge pull request #7861 from keymanapp/chore/common/stats

chore(common): stats script for planning
This commit is contained in:
Marc Durdin 2023-02-23 09:06:00 +11:00 committed by GitHub
commit c0ec8ba76c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 47 additions and 0 deletions

1
resources/stats/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
data/

View file

@ -0,0 +1,9 @@
{{range .}}{{
printf "%s\t%s\t%s\t%s\t%s\t%s\n"
(.number | printf "#%v" | autocolor "green")
.state
(.author.login | printf "%s" | autocolor "red")
.title
(.labels | pluck "name" | join "," | printf "%s" | autocolor "blue")
.createdAt
}}{{end}}

37
resources/stats/stats.sh Executable file
View file

@ -0,0 +1,37 @@
#!/usr/bin/env bash
set -e
set -u
## START STANDARD BUILD SCRIPT INCLUDE
# adjust relative paths as necessary
THIS_SCRIPT="$(greadlink -f "${BASH_SOURCE[0]}" 2>/dev/null || readlink -f "${BASH_SOURCE[0]}")"
. "$(dirname "$THIS_SCRIPT")/../build/build-utils.sh"
## END STANDARD BUILD SCRIPT INCLUDE
. "$KEYMAN_ROOT/resources/shellHelperFunctions.sh"
cd "$THIS_SCRIPT_PATH"
platforms=(android/ ios/ linux/ mac/ web/ windows/ developer/ core/ common/models/)
startdate=2022-05-01
stable=stable-15.0
STATS_ROOT="$KEYMAN_ROOT/resources/stats/data/"
mkdir -p "$STATS_ROOT"
echo -e "Platform\tAll PRs\t${stable}\tFeatures\tIssues" > "${STATS_ROOT}stats.tsv"
for p in "${platforms[@]}"; do
echo "Getting stats for $p"
mkdir -p "$STATS_ROOT/$p"
gh pr list --json author,createdAt,number,title,labels,state --template "$(cat gh-pr.txt)" --limit 1000 --search "created:>$startdate -label:auto label:$p" --state all > "$STATS_ROOT/${p}pulls.tsv"
gh pr list --json author,createdAt,number,title,labels,state --template "$(cat gh-pr.txt)" --limit 1000 --search "base:$stable created:>$startdate -label:auto label:$p" --state all > "$STATS_ROOT/${p}pulls-stable.tsv"
gh pr list --json author,createdAt,number,title,labels,state --template "$(cat gh-pr.txt)" --limit 1000 --search "created:>$startdate -label:auto label:feat label:$p" --state all > "$STATS_ROOT/${p}pulls-feat.tsv"
gh issue list --json author,createdAt,number,title,labels,state --template "$(cat gh-pr.txt)" --limit 1000 --search "created:>$startdate -label:auto label:$p" --state all > "$STATS_ROOT/${p}issues.tsv"
stat_all=`cat "$STATS_ROOT/${p}pulls.tsv" | wc -l`
stat_stable=`cat "$STATS_ROOT/${p}pulls-stable.tsv" | wc -l`
stat_feat=`cat "$STATS_ROOT/${p}pulls-feat.tsv" | wc -l`
stat_issues=`cat "$STATS_ROOT/${p}issues.tsv" | wc -l`
echo -e "$p\t$stat_all\t$stat_stable\t$stat_feat\t$stat_issues" >> "${STATS_ROOT}stats.tsv"
done