Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 1 | #!/bin/bash |
Joey Armstrong | 6890fa9 | 2024-08-15 12:14:37 -0400 | [diff] [blame] | 2 | ## ----------------------------------------------------------------------- |
| 3 | ## ----------------------------------------------------------------------- |
| 4 | |
| 5 | [[ ! -v JCL_resovled ]] && { declare -g -a JCL_resolved=(); } |
| 6 | |
| 7 | ## -------------------------------------------------------------------- |
| 8 | ## Intent: Retrieve a list of reason query strings |
| 9 | ## -------------------------------------------------------------------- |
| 10 | function get_jcl_resolved() |
| 11 | { |
| 12 | local -n ref=$1; shift |
Joey Armstrong | f8c78f0 | 2024-08-28 17:00:29 -0400 | [diff] [blame] | 13 | local -i count=${#ref[@]} |
Joey Armstrong | 6890fa9 | 2024-08-15 12:14:37 -0400 | [diff] [blame] | 14 | |
| 15 | local -a tmp=() |
| 16 | do_resolved tmp |
Joey Armstrong | f8c78f0 | 2024-08-28 17:00:29 -0400 | [diff] [blame] | 17 | |
| 18 | ## -------------------------- |
| 19 | ## Construct resolved queries |
| 20 | ## -------------------------- |
| 21 | local query="$(join_by ' OR ' "${tmp[@]}")" |
| 22 | |
| 23 | ## ---------------------------------------- |
| 24 | ## Normalize parens for the composite query |
| 25 | ## ---------------------------------------- |
| 26 | if [[ ${#ref[@]} -eq 0 ]]; then |
| 27 | ref+=("$query") |
| 28 | else |
| 29 | local buffer |
| 30 | buffer="$(join_by ' AND ' "(${ref[@]})" "($query)")" |
| 31 | ref=("$buffer") |
| 32 | fi |
Joey Armstrong | 6890fa9 | 2024-08-15 12:14:37 -0400 | [diff] [blame] | 33 | |
| 34 | return |
| 35 | } |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 36 | |
| 37 | ## -------------------------------------------------------------------- |
| 38 | ## Intent: Retrieve a list of reason query strings |
| 39 | ## -------------------------------------------------------------------- |
| 40 | function get_jql_reasons() |
| 41 | { |
| 42 | local -n ref=$1; shift |
| 43 | |
| 44 | ref+=('Cannot Reproduce') |
| 45 | ref+=('Duplicate') |
| 46 | ref+=('Fixed') |
| 47 | ref+=('Incomplete') |
| 48 | ref+=("Won't Do") |
| 49 | ref+=("Won't Fix") |
| 50 | return |
| 51 | } |
| 52 | |
| 53 | ## -------------------------------------------------------------------- |
| 54 | ## Intent: Modify search query by ticket resolution |
| 55 | ## -------------------------------------------------------------------- |
| 56 | function do_resolved() |
| 57 | { |
| 58 | declare -n ans=$1; shift |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 59 | |
Joey Armstrong | f8c78f0 | 2024-08-28 17:00:29 -0400 | [diff] [blame] | 60 | # --resolved-in {start} {end} can resolve join({and,or}) ambiguity |
| 61 | # [[ -v resolved_start ]] && { ans+=("(Resolved >= $resolved_start)"); } |
| 62 | # [[ -v resolved_end ]] && { ans+=("(Resolved <= $resolved_end)"); } |
| 63 | declare -a joinby=() |
| 64 | [[ -v resolved_start ]] && { joinby+=("(Resolved >= $resolved_start)"); } |
| 65 | [[ -v resolved_end ]] && { joinby+=("(Resolved <= $resolved_end)"); } |
| 66 | |
| 67 | if [[ ${#joinby[@]} -lt 2 ]]; then |
| 68 | ans+=("${joinby[@]}") |
| 69 | else |
| 70 | filter="$(join_by ' AND ' "${joinby[@]}")" |
| 71 | ans+=("(${filter})") |
| 72 | fi |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 73 | |
Joey Armstrong | f8c78f0 | 2024-08-28 17:00:29 -0400 | [diff] [blame] | 74 | |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 75 | if [[ -v resolved_excl ]]; then |
| 76 | filter="$(join_by ',' "${resolved_excl[@]}")" |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 77 | ans+=( "(resolution NOT IN ($filter))" ) |
| 78 | fi |
| 79 | |
| 80 | if [[ -v resolved_incl ]]; then |
| 81 | filter="$(join_by ',' "${resolved_incl[@]}")" |
| 82 | ans+=( "(resolution IN ($filter))" ) |
| 83 | fi |
| 84 | |
Joey Armstrong | f8c78f0 | 2024-08-28 17:00:29 -0400 | [diff] [blame] | 85 | if [[ -v resolved_not_empty ]]; then |
| 86 | ans+=('(resolved IS NOT EMPTY)') |
| 87 | elif [[ -v resolved_is_empty ]]; then |
| 88 | ans+=('(resolved IS EMPTY)') |
| 89 | fi |
| 90 | |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 91 | return |
| 92 | } |
| 93 | |
| 94 | : # ($?=0) for source $include |
| 95 | |
| 96 | # [EOF] |