From 7866057c8fdf1a6c29ba7ed72ece1e5246986663 Mon Sep 17 00:00:00 2001 From: Oliver Date: Tue, 1 Jul 2025 14:20:38 +0200 Subject: [PATCH] fix(custom-commands): learniing_time is only available for the current year --- omz-custom/custom_commands.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/omz-custom/custom_commands.sh b/omz-custom/custom_commands.sh index f1c2856..f9bc7ff 100755 --- a/omz-custom/custom_commands.sh +++ b/omz-custom/custom_commands.sh @@ -351,9 +351,10 @@ function learning_time() { USER_ID=300883 LEARNING_ID=21758966 + YEAR=$(date +%Y) INFO=$(curl --silent -u $PAYMO_TOKEN:f \ -H 'Accept: application/json' \ - --url "https://app.paymoapp.com/api/entries?where=user_id=$USER_ID") + --url "https://app.paymoapp.com/api/entries?where=user_id=$USER_ID%20and%20time_interval%20in%20(%22$YEAR-01-01T00%3A00%3A00.000Z%22%2C%22$YEAR-12-31T23%3A59%3A59.000Z%22)%20") LEARNING_TIME=$(jq "[.entries[] | select(.task_id==$LEARNING_ID) | .duration] | add" <<< "$INFO") TOTAL_TIME=$(jq "[.entries[] | .duration] | add" <<< "$INFO") # check if user added a parameter @@ -368,7 +369,7 @@ function learning_time() { LEARNING_DIFF=$(echo "scale=2; $TOTAL_LEARNING_TIME - $LEARNING_TIME" | bc) echo -e "Total time spent: ${CYAN}$TOTAL_TIME hours${NC}" - echo -e "Total learning time should be: ${CYAN}$TOTAL_LEARNING_TIME hours${NC}" + echo -e "Total learning time available: ${CYAN}$TOTAL_LEARNING_TIME hours${NC}" echo -e "Total learning time spent: ${CYAN}$LEARNING_TIME hours${NC}" if (( $(echo "$PERCENTAGE_LEARNING > 10" | bc -l) )); then echo -e "Percentage of time spent learning: ${RED}${PERCENTAGE_LEARNING}%${NC}"