From 529576e3960c8331ef442b804cb184066e0b3bf9 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 9 Apr 2024 21:07:15 +0200 Subject: [PATCH] Gracefully mark more than 50 notifications as done There is a built-in limit, therefore we need to batch the GraphQL call marking 50 notifications as done at a time. Otherwise we would run into this error message, and no notification would get marked done at all: gh: You can only mark up to 50 notifications as done. Signed-off-by: Johannes Schindelin --- gh-clean-notifications | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gh-clean-notifications b/gh-clean-notifications index e7d3f60..159d0d0 100755 --- a/gh-clean-notifications +++ b/gh-clean-notifications @@ -1,7 +1,6 @@ #!/usr/bin/env bash set -e - NOTIFICATION_QUERY="query NotificationsQuery(\$first: Int!, \$endCursor: String, \$miscQuery: String) { viewer { notificationThreads(first: \$first, after: \$endCursor, query: \$miscQuery) { @@ -157,8 +156,14 @@ process_notifications() { echo "Marking as Done: $(echo "${item}" | jq -r .title)" echo " https://github.com$(echo "${item}" | jq -r .path)" IDS+=(-f "ids[]=$(echo "${item}" | jq -r .id)") + if test ${#IDS[@]} -eq 100 + then + gh api graphql --silent "${IDS[@]}" -f query="${MARK_IDS_AS_DONE_QUERY}" + IDS=() + fi done + test ${#IDS[@]} -eq 0 || gh api graphql --silent "${IDS[@]}" -f query="${MARK_IDS_AS_DONE_QUERY}" else