| #!/bin/bash |
| ## ----------------------------------------------------------------------- |
| ## ----------------------------------------------------------------------- |
| |
| [[ ! -v JCL_resovled ]] && { declare -g -a JCL_resolved=(); } |
| |
| ## -------------------------------------------------------------------- |
| ## Intent: Retrieve a list of reason query strings |
| ## -------------------------------------------------------------------- |
| function get_jcl_resolved() |
| { |
| local -n ref=$1; shift |
| local -i count=${#ref[@]} |
| |
| local -a tmp=() |
| do_resolved tmp |
| |
| ## -------------------------- |
| ## Construct resolved queries |
| ## -------------------------- |
| local query="$(join_by ' OR ' "${tmp[@]}")" |
| |
| ## ---------------------------------------- |
| ## Normalize parens for the composite query |
| ## ---------------------------------------- |
| if [[ ${#ref[@]} -eq 0 ]]; then |
| ref+=("$query") |
| else |
| local buffer |
| buffer="$(join_by ' AND ' "(${ref[@]})" "($query)")" |
| ref=("$buffer") |
| fi |
| |
| return |
| } |
| |
| ## -------------------------------------------------------------------- |
| ## Intent: Retrieve a list of reason query strings |
| ## -------------------------------------------------------------------- |
| function get_jql_reasons() |
| { |
| local -n ref=$1; shift |
| |
| ref+=('Cannot Reproduce') |
| ref+=('Duplicate') |
| ref+=('Fixed') |
| ref+=('Incomplete') |
| ref+=("Won't Do") |
| ref+=("Won't Fix") |
| return |
| } |
| |
| ## -------------------------------------------------------------------- |
| ## Intent: Modify search query by ticket resolution |
| ## -------------------------------------------------------------------- |
| function do_resolved() |
| { |
| declare -n ans=$1; shift |
| |
| # --resolved-in {start} {end} can resolve join({and,or}) ambiguity |
| # [[ -v resolved_start ]] && { ans+=("(Resolved >= $resolved_start)"); } |
| # [[ -v resolved_end ]] && { ans+=("(Resolved <= $resolved_end)"); } |
| declare -a joinby=() |
| [[ -v resolved_start ]] && { joinby+=("(Resolved >= $resolved_start)"); } |
| [[ -v resolved_end ]] && { joinby+=("(Resolved <= $resolved_end)"); } |
| |
| if [[ ${#joinby[@]} -lt 2 ]]; then |
| ans+=("${joinby[@]}") |
| else |
| filter="$(join_by ' AND ' "${joinby[@]}")" |
| ans+=("(${filter})") |
| fi |
| |
| |
| if [[ -v resolved_excl ]]; then |
| filter="$(join_by ',' "${resolved_excl[@]}")" |
| ans+=( "(resolution NOT IN ($filter))" ) |
| fi |
| |
| if [[ -v resolved_incl ]]; then |
| filter="$(join_by ',' "${resolved_incl[@]}")" |
| ans+=( "(resolution IN ($filter))" ) |
| fi |
| |
| if [[ -v resolved_not_empty ]]; then |
| ans+=('(resolved IS NOT EMPTY)') |
| elif [[ -v resolved_is_empty ]]; then |
| ans+=('(resolved IS EMPTY)') |
| fi |
| |
| return |
| } |
| |
| : # ($?=0) for source $include |
| |
| # [EOF] |