openproject_hours: refactor
This commit is contained in:
parent
014343790c
commit
8db3a4adf0
1 changed files with 27 additions and 20 deletions
|
@ -1,4 +1,5 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
# vim: noet ci pi sts=0 sw=4 ts=4
|
||||||
|
|
||||||
year=$1
|
year=$1
|
||||||
month=$2
|
month=$2
|
||||||
|
@ -8,28 +9,34 @@ API_KEY="<#openproject_apikey#>"
|
||||||
API_URL="https://op.tralios.de"
|
API_URL="https://op.tralios.de"
|
||||||
PAGE_SIZE="1000"
|
PAGE_SIZE="1000"
|
||||||
|
|
||||||
filters='[
|
days=$(cal "$month" "$year" | awk 'NF {DAYS=$NF} END {print DAYS}')
|
||||||
{
|
|
||||||
"spentOn": {
|
filters=$(
|
||||||
"operator": "<>d",
|
cat <<-EOF
|
||||||
"values": ["'"${year}-${month}-01"'", "'"${year}-${month}-30"'"]
|
[
|
||||||
}
|
{
|
||||||
},
|
"spentOn": {
|
||||||
{
|
"operator": "<>d",
|
||||||
"user": {
|
"values": ["${year}-${month}-01", "${year}-${month}-${days}"]
|
||||||
"operator": "=",
|
}
|
||||||
"values": ["'"$USER_ID"'"]
|
},
|
||||||
}
|
{
|
||||||
}
|
"user": {
|
||||||
]'
|
"operator": "=",
|
||||||
|
"values": ["$USER_ID"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
|
||||||
curl -s \
|
curl -s \
|
||||||
-u "apikey:${API_KEY}" \
|
-u "apikey:${API_KEY}" \
|
||||||
-G "${API_URL}/api/v3/time_entries" \
|
-G "${API_URL}/api/v3/time_entries" \
|
||||||
--data-urlencode "filters=${filters}" \
|
--data-urlencode "filters=${filters}" \
|
||||||
--data-urlencode "pageSize=${PAGE_SIZE}" |
|
--data-urlencode "pageSize=${PAGE_SIZE}" |
|
||||||
jq -r '._embedded.elements | map(.hours) | join(" ")' |
|
jq -r '._embedded.elements | map(.hours) | join(" ")' |
|
||||||
awk '{
|
awk '{
|
||||||
gsub(/PT/, "");
|
gsub(/PT/, "");
|
||||||
gsub(/H/, "H ");
|
gsub(/H/, "H ");
|
||||||
gsub(/M/, "M ");
|
gsub(/M/, "M ");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue