From 638dedf7410bd8942b3759564bf79deb051c1b85 Mon Sep 17 00:00:00 2001 From: leonsteinhaeuser Date: Thu, 14 Jul 2022 22:03:02 +0200 Subject: [PATCH] feature: implemented @current and @next iteration selection To use this functionality, simply pass @current or @next as the iteration value. --- gh_api_lib_organization.sh | 20 +++++++++++++++++--- gh_api_lib_user.sh | 20 +++++++++++++++++--- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/gh_api_lib_organization.sh b/gh_api_lib_organization.sh index f4bf35c..15858fb 100644 --- a/gh_api_lib_organization.sh +++ b/gh_api_lib_organization.sh @@ -40,10 +40,24 @@ function extractOrganizationFieldID() { # extractOrganizationFieldNodeIterationSettingValue returns the field node setting value id # 1: field name # 2: select value +# +# NOTE: If the value is @current or @next, we check the the array of iterations and return the current or next iteration id. function extractOrganizationFieldNodeIterationSettingValue() { - local fieldName=$(echo $1 | sed -e "s+\"++g") # remove quotes - selectValue=$(echo $2 | sed -e "s+\"++g") # remove quotes - jq ".data.organization.projectNext.fields.nodes[] | select(.name == \"$fieldName\").settings | fromjson.configuration.iterations[] | select(.title==\"$selectValue\") |.id" $TMP_STORE_LOCATION | sed -e "s+\"++g" + local field_name=$(echo $1 | sed -e "s+\"++g") # remove quotes + select_value=$(echo $2 | sed -e "s+\"++g") # remove quotes + + iterations_for_field=$(jq ".data.organization.projectNext.fields.nodes[] | select(.name==\"$field_name\").settings | fromjson.configuration.iterations[]" $TMP_STORE_LOCATION) + dates=$(echo $iterations_for_field | jq -r ".start_date" | sort ) + STRINGTEST=(${dates[@]}) + if [ "$select_value" == "@current" ]; then + iteration_selected=${STRINGTEST[0]} + echo -e $iterations_for_field | jq "select(.start_date==\"$iteration_selected\") |.id" | sed -e "s+\"++g" + elif [ "$select_value" == "@next" ]; then + iteration_selected=${STRINGTEST[1]} + echo -e $iterations_for_field | jq "select(.start_date==\"$iteration_selected\") |.id" | sed -e "s+\"++g" + else + echo -e $iterations_for_field | jq "select(.title==\"$select_value\") |.id" | sed -e "s+\"++g" + fi } # extractOrganizationFieldNodeSelectSettingValue returns the field node setting value id diff --git a/gh_api_lib_user.sh b/gh_api_lib_user.sh index ff3b15d..4efd72d 100644 --- a/gh_api_lib_user.sh +++ b/gh_api_lib_user.sh @@ -40,10 +40,24 @@ function extractUserFieldID() { # extractUserFieldNodeIterationSettingValue returns the field node setting value id # 1: field name # 2: select value +# +# NOTE: If the value is @current or @next, we check the the array of iterations and return the current or next iteration id. function extractUserFieldNodeIterationSettingValue() { - local fieldName=$(echo $1 | sed -e "s+\"++g") # remove quotes - selectValue=$(echo $2 | sed -e "s+\"++g") # remove quotes - jq ".data.user.projectNext.fields.nodes[] | select(.name == \"$fieldName\").settings | fromjson.configuration.iterations[] | select(.title==\"$selectValue\") |.id" $TMP_STORE_LOCATION | sed -e "s+\"++g" + local field_name=$(echo $1 | sed -e "s+\"++g") # remove quotes + select_value=$(echo $2 | sed -e "s+\"++g") # remove quotes + + iterations_for_field=$(jq ".data.user.projectNext.fields.nodes[] | select(.name==\"$field_name\").settings | fromjson.configuration.iterations[]" $TMP_STORE_LOCATION) + dates=$(echo $iterations_for_field | jq -r ".start_date" | sort ) + STRINGTEST=(${dates[@]}) + if [ "$select_value" == "@current" ]; then + iteration_selected=${STRINGTEST[0]} + echo -e $iterations_for_field | jq "select(.start_date==\"$iteration_selected\") |.id" | sed -e "s+\"++g" + elif [ "$select_value" == "@next" ]; then + iteration_selected=${STRINGTEST[1]} + echo -e $iterations_for_field | jq "select(.start_date==\"$iteration_selected\") |.id" | sed -e "s+\"++g" + else + echo -e $iterations_for_field | jq "select(.title==\"$select_value\") |.id" | sed -e "s+\"++g" + fi } # extractUserFieldNodeSelectSettingValue returns the field node setting value id