17
2
Fork 0
Misc tools created for the maintenance of the XMPP services at chapril.org.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.1 KiB

#! /bin/bash
REDMINE_BASE_URL="https://agir.april.org"
TICKET_ID=4047
REPORT_COMMAND="/usr/local/sbin/display_activity_report"
if [ 'z' = "z${API_KEY}" ]; then
echo "Missing environment variable API_KEY" >&2
exit 1
fi
main() {
post_report
}
post_report() {
datafile=$(mktemp /tmp/report_stats_$(date +%Y-%m-%d_%H%M)_XXXX.json)
cat <<EOF > "${datafile}"
{
"issue": {
"notes": "$(${REPORT_COMMAND} | sed -z 's/\n/\\n/g')"
}
}
EOF
curl -s \
-H "Content-Type: application/json" \
-H "X-Redmine-API-Key: ${API_KEY}" \
-X PUT --data-binary "@${datafile}" \
"${REDMINE_BASE_URL}/issues/${TICKET_ID}.json"
rm "${datafile}"
}
# debug function
last_comment_date() {
curl -H "X-Redmine-API-Key: ${API_KEY}" -s "${REDMINE_BASE_URL}/issues/${TICKET_ID}.json?include=journals" \
| jq '.issue.journals | last | .created_on'
}
# debug function
list() {
curl -H "X-Redmine-API-Key: ${API_KEY}" -s "${REDMINE_BASE_URL}/issues/${TICKET_ID}.json?include=journals" \
| jq '.issue.journals[] | [.user.name, .notes]'
}
main