From 29093c643d9cfb7eba7b8009a5b0afe4a93474d7 Mon Sep 17 00:00:00 2001 From: Zach DeCook Date: Wed, 20 May 2026 11:22:38 -0400 Subject: Cache results (for when github is down), also only get tickets from an active sprint --- .local/bin/jira-CR.php | 27 +++++++++++++++++++-------- 1 file 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"); -- cgit 1.4.1