Skip to content

Commit

Permalink
Merge pull request nushell#44 from fdncred/this_week_in_nu
Browse files Browse the repository at this point in the history
prototype of TWiN automation script
  • Loading branch information
fdncred committed Apr 26, 2021
2 parents 617a3d7 + e4b0c26 commit bfb0929
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions this_week_in_nu.nu
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# fetch https://api.github.com/repos/nushell/nushell/pulls?q=is%3Apr+merged%3A%3E%3D2021-04-20+ | select url user.login title body
# 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
]; [Nushell nushell
] [Extension vscode-nushell-lang
] [Documentation nushell.github.io
] [Wasm demo
] [Nu_Scripts nu_scripts
] [RFCs rfcs]
# ] [Jupyter jupyter]
]

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" $query_date)

# echo $site_table

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?) {

} {
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
})
if $(= $entries | empty?) {

} {
echo $entries | str collect
}
}


build-string '# This week in Nushell #' $(char nl) $(char nl)
do-work | str collect

0 comments on commit bfb0929

Please sign in to comment.