Skip to content

Commit

Permalink
feature: implemented @current and @next iteration selection
Browse files Browse the repository at this point in the history
To use this functionality, simply pass @current or @next as the iteration value.
  • Loading branch information
leonsteinhaeuser committed Jul 14, 2022
1 parent 5f5211c commit 638dedf
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
20 changes: 17 additions & 3 deletions gh_api_lib_organization.sh
Expand Up @@ -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
Expand Down
20 changes: 17 additions & 3 deletions gh_api_lib_user.sh
Expand Up @@ -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
Expand Down

0 comments on commit 638dedf

Please sign in to comment.