blob: cf6bf3168313c6e5aacd2bb85be8d014720c64f1 [file] [log] [blame]
Joey Armstrong3134bfd2024-02-10 20:51:25 -05001#!/bin/bash
Joey Armstrong6890fa92024-08-15 12:14:37 -04002## -----------------------------------------------------------------------
3## -----------------------------------------------------------------------
4
5[[ ! -v JCL_resovled ]] && { declare -g -a JCL_resolved=(); }
6
7## --------------------------------------------------------------------
8## Intent: Retrieve a list of reason query strings
9## --------------------------------------------------------------------
10function get_jcl_resolved()
11{
12 local -n ref=$1; shift
Joey Armstrongf8c78f02024-08-28 17:00:29 -040013 local -i count=${#ref[@]}
Joey Armstrong6890fa92024-08-15 12:14:37 -040014
15 local -a tmp=()
16 do_resolved tmp
Joey Armstrongf8c78f02024-08-28 17:00:29 -040017
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 Armstrong6890fa92024-08-15 12:14:37 -040033
34 return
35}
Joey Armstrong3134bfd2024-02-10 20:51:25 -050036
37## --------------------------------------------------------------------
38## Intent: Retrieve a list of reason query strings
39## --------------------------------------------------------------------
40function 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## --------------------------------------------------------------------
56function do_resolved()
57{
58 declare -n ans=$1; shift
Joey Armstrong3134bfd2024-02-10 20:51:25 -050059
Joey Armstrongf8c78f02024-08-28 17:00:29 -040060 # --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 Armstrong3134bfd2024-02-10 20:51:25 -050073
Joey Armstrongf8c78f02024-08-28 17:00:29 -040074
Joey Armstrong3134bfd2024-02-10 20:51:25 -050075 if [[ -v resolved_excl ]]; then
76 filter="$(join_by ',' "${resolved_excl[@]}")"
Joey Armstrong3134bfd2024-02-10 20:51:25 -050077 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 Armstrongf8c78f02024-08-28 17:00:29 -040085 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 Armstrong3134bfd2024-02-10 20:51:25 -050091 return
92}
93
94: # ($?=0) for source $include
95
96# [EOF]