diff options
| author | Zach DeCook <zach.decook@bettercarpeople.com> | 2026-05-20 11:22:38 -0400 |
|---|---|---|
| committer | Zach DeCook <zach.decook@bettercarpeople.com> | 2026-05-20 11:22:38 -0400 |
| commit | 29093c643d9cfb7eba7b8009a5b0afe4a93474d7 (patch) | |
| tree | 520344cb59b2a0cfef8f76f13381815b09335e08 /.local/bin/jira-CR.php | |
| parent | 322a14124e504b048fd5e5ae215c93e4cd36a70e (diff) | |
| download | dotfiles-29093c643d9cfb7eba7b8009a5b0afe4a93474d7.tar.gz | |
Cache results (for when github is down), also only get tickets from an active sprint bcp
Diffstat (limited to '.local/bin/jira-CR.php')
| -rwxr-xr-x | .local/bin/jira-CR.php | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/.local/bin/jira-CR.php b/.local/bin/jira-CR.php index a4d16c8..6da5d7b 100755 --- a/.local/bin/jira-CR.php +++ b/.local/bin/jira-CR.php @@ -22,22 +22,33 @@ $ansireset = "\033[0m"; $padlen = 50; print(str_pad("\rGetting tickets from jira...", $padlen)); -$ticket_lines = explode("\n", rtrim(shell_exec("jira-cli issues list -q'project IS NOT EMPTY and project != AUTO and project != NET and project != MSP and project != SYST and project != LOYAL' --order-by='Sprint' -s'Code Review' --columns=KEY,LABELS --plain | grep -v '^KEY\b'"))); +$ticket_lines = explode("\n", rtrim(shell_exec("jira-cli issues list -q'project IS NOT EMPTY and project != AUTO and project != NET and project != MSP and project != SYST and project != LOYAL and Sprint in openSprints()' --order-by='Sprint' -s'Code Review' --columns=KEY,LABELS --plain | grep -v '^KEY\b'"))); $tickets = array_map(fn($x) => explode("\t", $x)[0], $ticket_lines); $ticketLabels = array_combine( $tickets, array_map(fn($x) => explode(',', explode("\t", $x)[1] ?? ''), $ticket_lines) ); -$params = 'title,url,statusCheckRollup,reviews,author,reviewDecision,reviewRequests,headRefName,mergeable,additions,deletions'; + +function get_gh(string $repo): array { + $padlen = 50; + $params = 'title,url,statusCheckRollup,reviews,author,reviewDecision,reviewRequests,headRefName,mergeable,additions,deletions'; + print(str_pad("\rGetting $repo PR's from github...", $padlen)); + try { + $data = json_decode(shell_exec("gh pr list -L 50 -R BetterCarPeople/$repo --json '$params'"), true); + if (array_filter($data)) { + file_put_contents("/tmp/prs_$repo.json", json_encode($data)); + return $data; + } + } catch (\Throwable $e) { + } + return json_decode(shell_exec("cat /tmp/prs_$repo.json"), true); +} $prs_jsons = []; -print(str_pad("\rGetting OnBDC2 PR's from github...", $padlen)); -$prs_jsons[] = json_decode(shell_exec("gh pr list -L 50 -R BetterCarPeople/OnBDC2 --json '$params'"), true); -print(str_pad("\rGetting maple-ai PR's from github...", $padlen)); -$prs_jsons[] = json_decode(shell_exec("gh pr list -R BetterCarPeople/maple-ai --json '$params'"), true); -print(str_pad("\rGetting maple-web PR's from github...", $padlen)); -$prs_jsons[] = json_decode(shell_exec("gh pr list -R BetterCarPeople/maple-web --json '$params'"), true); +$prs_jsons[] = get_gh("OnBDC2"); +$prs_jsons[] = get_gh("maple-ai"); +$prs_jsons[] = get_gh("maple-web"); print(str_pad("\r", $padlen)); print("\r"); |
