summary refs log tree commit diff
path: root/.local
diff options
context:
space:
mode:
Diffstat (limited to '.local')
-rwxr-xr-x.local/bin/jira-ticketstatus.php82
1 files changed, 82 insertions, 0 deletions
diff --git a/.local/bin/jira-ticketstatus.php b/.local/bin/jira-ticketstatus.php
new file mode 100755
index 0000000..2a50751
--- /dev/null
+++ b/.local/bin/jira-ticketstatus.php
@@ -0,0 +1,82 @@
+#!/usr/bin/env php
+<?php
+if (empty(trim($argv[1]))) {
+    echo "Please paste the tickets as an argument";
+    exit(3);
+}
+$tickets = array_unique(array_filter(explode(' ', strtr($argv[1], "\n\t\"", '   '))));
+
+function rgb(int $r, int $g, int $b): string {
+    $blacktext = "\033[38;2;0;0;0m";
+    return $blacktext . "\033[48;2;{$r};{$g};{$b}m";
+}
+
+function status_to_ansi(string $status): string {
+    $ansired = "\033[31m";
+    $ansigreen = "\033[32m";
+    $ansiyellow = "\033[33m";
+    $ansiblue = "\033[34m";
+    $ansimagenta = "\033[35m"; // pink
+    $ansicyan = "\033[36m";
+    $ansireset = "\033[0m";
+    $ansibrightblue = "\033[94m"; // purple
+    return match($status) {
+        "Blocked" => rgb(252, 229, 205), //$ansiyellow, #fce5cd
+        "Ready To Work" => $ansireset,
+        "In Progress" => rgb(230, 184, 175), //$ansired, #e6b8af
+        "Code Review" => rgb(234, 209, 220), //$ansimagenta, #ead1dc
+        "Pending Demo",
+        "Ready To Test", "Testing" => rgb(217, 210, 233), //$ansibrightblue, #d9d2e9
+        "Pending Sign Off", "Signed Off",
+        "Ready To Deploy",
+        "Obsolete", "Done" => rgb(207, 226, 243), // $ansiblue, #cfe2f3
+        default => $ansireset,
+    };
+}
+
+//echo implode(' ', $tickets);
+//exit(1);
+$keys = implode(',', array_filter($tickets, fn($x) => str_starts_with($x, 'LAMP-')));
+$command =  "jira-cli issues list -q 'project = LAMP and key in ($keys)' --columns=KEY,STATUS --plain | grep -v '^KEY\b'";
+//echo $command;
+$jira_tickets = explode("\n", rtrim(shell_exec($command)));
+$ticket_status = [];
+$search = $replace = [];
+foreach ($jira_tickets as $jira_ticket) {
+    [$key, $status] = explode("\t", $jira_ticket);
+    $ticket_status[$key] = $status;
+    $search[] = $key;
+    $replace[] = status_to_ansi($status) . $key . "\033[0m";
+    // $search_replace[$key] = 
+}
+echo "\n";
+echo str_replace($search, $replace, $argv[1]);
+echo "\n";
+
+return;
+
+$padlen = 50;
+print(str_pad("\rGetting ready to work tickets from jira...", $padlen));
+$RTWtickets = explode("\n", rtrim(`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 project != ONBDCA" --order-by="Sprint" -s"Ready To Work" --columns=KEY --plain | grep -v '^KEY$'`));
+print(str_pad("\rGetting blocked tickets from jira...", $padlen));
+$BLOCKtickets = explode("\n", rtrim(`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"Blocked" -s"Needs Ops Refinement" --columns=KEY --plain | grep -v '^KEY$'`));
+print(str_pad("\rGetting in progress tickets from jira...", $padlen));
+$IPtickets = explode("\n", rtrim(`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 project != BCP" --order-by="Sprint" -s"In Progress" --columns=KEY --plain | grep -v '^KEY$'`));
+print(str_pad("\rGetting code review tickets from jira...", $padlen));
+$CRtickets = explode("\n", rtrim(`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 --plain | grep -v '^KEY$'`));
+print(str_pad("\rGetting testing tickets from jira...", $padlen));
+$TESTtickets = explode("\n", rtrim(`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"Pending Demo" -s"Ready To Test" -s "Testing" --columns=KEY --plain | grep -v '^KEY$'`));
+print(str_pad("\rGetting done tickets from jira...", $padlen));
+$DONEtickets = explode("\n", rtrim(`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 project != BCP and project != 'DO' and project != SC and project != ONBDCA" --order-by="Sprint" -s"Pending Sign Off" -s "Signed Off" -s"Done" --columns=KEY --plain | grep -v '^KEY$'`));
+print(str_pad("\r", $padlen));
+print("\r");
+
+
+echo "Ready To Work: " . implode(' ', array_intersect($tickets, $RTWtickets)) . "\n";
+echo "Blocked: " . implode(' ', array_intersect($tickets, $BLOCKtickets)) . "\n";
+echo "In Progress: " . implode(' ', array_intersect($tickets, $IPtickets)) . "\n";
+echo "Code Review: " . implode(' ', array_intersect($tickets, $CRtickets)) . "\n";
+echo "Testing: " . implode(' ', array_intersect($tickets, $TESTtickets)) . "\n";
+echo "Done: " . implode(' ', array_intersect($tickets, $DONEtickets)) . "\n";
+
+echo "Unknown: " . implode(' ', array_diff($tickets, $RTWtickets, $BLOCKtickets, $IPtickets, $CRtickets, $TESTtickets, $DONEtickets, ['/', 'PTO'])) . "\n";