| 1 |
#!/usr/bin/env nu |
| 2 |
|
| 3 |
def query-week-span [] { |
| 4 |
let site_table = [ |
| 5 |
[site repo]; |
| 6 |
[Nushell nushell] |
| 7 |
[Extension vscode-nushell-lang] |
| 8 |
[Documentation nushell.github.io] |
| 9 |
[Wasm demo] |
| 10 |
[Nu_Scripts nu_scripts] |
| 11 |
[RFCs rfcs] |
| 12 |
[reedline reedline] |
| 13 |
[Nana nana] |
| 14 |
# ] [Jupyter jupyter] |
| 15 |
] |
| 16 |
|
| 17 |
let query_prefix = "https://api.github.com/search/issues?q=repo:nushell/" |
| 18 |
let query_date = (seq date --days 7 -r | get 6) |
| 19 |
let per_page = "100" |
| 20 |
let page_num = "1" # need to implement iterating pages |
| 21 |
let colon = "%3A" |
| 22 |
let gt = "%3E" |
| 23 |
let eq = "%3D" |
| 24 |
let amp = "%26" |
| 25 |
let query_suffix = $"+is($colon)pr+is($colon)merged+merged($colon)($gt)($eq)($query_date)&per_page=100&page=1" |
| 26 |
|
| 27 |
for repo in $site_table { |
| 28 |
let query_string = $"($query_prefix)($repo.repo)($query_suffix)" |
| 29 |
let site_json = ( |
| 30 |
http get -u $env.GITHUB_USERNAME -p $env.GITHUB_PASSWORD $query_string |
| 31 |
| get items |
| 32 |
| select html_url user.login title |
| 33 |
) |
| 34 |
|
| 35 |
if not ($site_json | all { |it| $it | is-empty }) { |
| 36 |
print $"(char nl)## ($repo.site)(char nl)" |
| 37 |
|
| 38 |
for user in ($site_json | group-by user_login | transpose user prs) { |
| 39 |
let user_name = $user.user |
| 40 |
let pr_count = ($user.prs | length) |
| 41 |
|
| 42 |
print -n $"- ($user_name) created " |
| 43 |
for pr in ($user.prs | enumerate) { |
| 44 |
if $pr_count == ($pr.index + 1) { |
| 45 |
print -n $"[($pr.item.title)](char lparen)($pr.item.html_url)(char rparen)" |
| 46 |
} else { |
| 47 |
print -n $"[($pr.item.title)](char lparen)($pr.item.html_url)(char rparen), and " |
| 48 |
} |
| 49 |
} |
| 50 |
|
| 51 |
print "" |
| 52 |
} |
| 53 |
} |
| 54 |
} |
| 55 |
} |
| 56 |
|
| 57 |
# 2019-08-23 was the release of 0.2.0, the first public release |
| 58 |
let week_num = ((seq date -b '2019-08-23' -n 7 | length) - 1) |
| 59 |
print $"# This week in Nushell #($week_num)(char nl)" |
| 60 |
|
| 61 |
if ($env | select GITHUB_USERNAME | is-empty) or ($env | select GITHUB_PASSWORD | is-empty) { |
| 62 |
print 'Please set GITHUB_USERNAME and GITHUB_PASSWORD in $env to use this script' |
| 63 |
} else { |
| 64 |
query-week-span |
| 65 |
} |
| 66 |
|
| 67 |
# From https://github.com/nushell/nu_scripts/blob/main/make_release/this_week_in_nu_weekly.nu |
| 68 |
|