Skip to content

Commit

Permalink
Gracefully mark more than 50 notifications as done
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
dscho authored and paulbarton90 committed Apr 9, 2024
1 parent 263e556 commit 529576e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion gh-clean-notifications
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 529576e

Please sign in to comment.