1
Fork 0
mirror of https://github.com/RGBCube/nu_scripts synced 2025-08-01 06:37:46 +00:00

table grouping experiment, update twin to support single user per row

This commit is contained in:
Darren Schroeder 2021-05-06 17:41:26 -05:00
parent e78dbe449b
commit 53de81f33b
2 changed files with 80 additions and 13 deletions

47
table_grouping.nu Normal file
View file

@ -0,0 +1,47 @@
let table = $(echo [
[url user_login title
]; [https://api.github.com/repos/nushell/nushell/issues/3382 ammkrn 'Dont unwrap rustyline helper in cli'
] [https://api.github.com/repos/nushell/nushell/issues/3379 jonathandturner 'Simplify down to one type of context'
] [https://api.github.com/repos/nushell/nushell/issues/3377 kubouch 'Port range to engine-p'
] [https://api.github.com/repos/nushell/nushell/issues/3375 fdncred 'added check for endian-ness, added a bytes and skip'
] [https://api.github.com/repos/nushell/nushell/issues/3374 fdncred 'added ability to change "#" color using header_color'
] [https://api.github.com/repos/nushell/nushell/issues/3370 fdncred 'add nu-pretty-hex, add into binary, update binaryview'
] [https://api.github.com/repos/nushell/nushell/issues/3367 fdncred 'tweaked the error handling to show specific errors']
])
echo $table
build-string '## Nushell' $(char nl) $(char nl)
echo $table | group-by user_login | pivot user prs | each {
let user_name = $it.user
let pr_count = $(echo $it.prs | length)
# only print the comma if there's another item
let user_prs = $(echo $it.prs | each -n {
if $pr_count == $(= $it.index + 1) {
build-string '[' $it.item.title '](' $it.item.url ')'
} {
build-string '[' $it.item.title '](' $it.item.url '), and '
}
} | str collect)
build-string '- ' $user_name ' created ' $user_prs $(char nl)
} | str collect
# ╭───┬──────────────────────────────────────────────────────────┬─────────────────┬───────────────────────────────────────────────────────╮
# │ # │ url │ user_login │ title │
# ├───┼──────────────────────────────────────────────────────────┼─────────────────┼───────────────────────────────────────────────────────┤
# │ 0 │ https://api.github.com/repos/nushell/nushell/issues/3382 │ ammkrn │ Dont unwrap rustyline helper in cli │
# │ 1 │ https://api.github.com/repos/nushell/nushell/issues/3379 │ jonathandturner │ Simplify down to one type of context │
# │ 2 │ https://api.github.com/repos/nushell/nushell/issues/3377 │ kubouch │ Port range to engine-p │
# │ 3 │ https://api.github.com/repos/nushell/nushell/issues/3375 │ fdncred │ added check for endian-ness, added a bytes and skip │
# │ 4 │ https://api.github.com/repos/nushell/nushell/issues/3374 │ fdncred │ added ability to change "#" color using header_color │
# │ 5 │ https://api.github.com/repos/nushell/nushell/issues/3370 │ fdncred │ add nu-pretty-hex, add into binary, update binaryview │
# │ 6 │ https://api.github.com/repos/nushell/nushell/issues/3367 │ fdncred │ tweaked the error handling to show specific errors │
# ╰───┴──────────────────────────────────────────────────────────┴─────────────────┴───────────────────────────────────────────────────────╯
def log [message:any] {
let now = $(date now | date format '%Y%m%d_%H%M%S.%f')
let mess = $(build-string $now '|DBG|' $message $(char newline))
echo $mess | autoview
}

View file

@ -2,9 +2,6 @@
# fetch https://api.github.com/search/issues?q=repo:nushell/vscode-nushell-lang+is:pr+is:merged+merged:%3E2021-04-01 | get items | select url user.login title body
# Repos to monitor
# TODO - group-by user so all there PRs are on one line
# TODO - automatically figure out what week it is
def do-work [] {
let site_table = [
[site url
@ -19,30 +16,53 @@ def do-work [] {
let query_prefix = "https://api.github.com/search/issues?q=repo:nushell/"
let query_date = $(seq date --days 7 -r | last)
# let query_select = " | get items | select url user.login title"
let query_suffix = $(build-string "+is:pr+is:merged+merged:%3E%3D" $query_date)
# echo $site_table
# let entries = $(echo $site_table | each {
# let query_string = $(build-string $query_prefix $it.url $query_suffix)
# let site_json = $(fetch $query_string | get items | select url user.login title)
# build-string '## ' $(echo $it.site) $(char nl) $(char nl)
# if $(= $site_json | empty?) {
# } {
# echo $site_json | each {
# build-string '- ' $it.user_login ' created [' $it.title '](' $it.url ')' $(char nl)
# } | str collect
# build-string $(char nl)
# }
# # We need 2 seconds between fetches or github's api limiting will limit us
# sleep 2sec
# })
let entries = $(echo $site_table | each {
let query_string = $(build-string $query_prefix $it.url $query_suffix)
# debug string
# build-string 'fetch ' $query_string $(char nl) | autoview
# fetch $query_string
let site_json = $(fetch $query_string | get items | select url user.login title)
# echo $site_json | autoview
build-string '## ' $(echo $it.site) $(char nl) $(char nl)
if $(= $site_json | empty?) {
build-string "none found this week" $(char nl) $(char nl)
} {
echo $site_json | each {
build-string '- ' $it.user_login ' created [' $it.title '](' $it.url ')' $(char nl)
echo $site_json | group-by user_login | pivot user prs | each {
let user_name = $it.user
let pr_count = $(echo $it.prs | length)
# only print the comma if there's another item
let user_prs = $(echo $it.prs | each -n {
if $pr_count == $(= $it.index + 1) {
build-string '[' $it.item.title '](' $it.item.url ')'
} {
build-string '[' $it.item.title '](' $it.item.url '), and '
}
} | str collect)
build-string '- ' $user_name ' created ' $user_prs $(char nl)
} | str collect
build-string $(char nl)
}
}
# We need 2 seconds between fetches or github's api limiting will limit us
sleep 2sec
})
if $(= $entries | empty?) {
} {