@@ -132,12 +132,31 @@ echo "$ALL_ISSUES_JSON" | jq -c '.' | while read -r ISSUE_JSON; do
132132 fi
133133
134134 # Get assignment time (use the last assigned event)
135- ASSIGN_TS=$( gh api " repos/$REPO /issues/$ISSUE /events" \
136- --jq " .[] | select(.event==\" assigned\" ) | .created_at" \
137- | tail -n1)
135+ if ! ASSIGN_TS=$( gh api graphql -f query="
136+ query {
137+ repository(owner: \" ${REPO%/* } \" , name: \" ${REPO#*/ } \" ) {
138+ issue(number: $ISSUE ) {
139+ timelineItems(itemTypes: [ASSIGNED_EVENT], last: 1) {
140+ nodes {
141+ ... on AssignedEvent {
142+ createdAt
143+ assignee {
144+ __typename
145+ ... on User { login }
146+ }
147+ }
148+ }
149+ }
150+ }
151+ }
152+ }
153+ " --jq ' .data.repository.issue.timelineItems.nodes[0].createdAt' 2>&1 ) ; then
154+ echo " [WARN] GraphQL query failed for issue #$ISSUE : $ASSIGN_TS . Skipping."
155+ continue
156+ fi
138157
139- if [ -z " $ASSIGN_TS " ]; then
140- echo " [WARN] No assignment event found. Skipping."
158+ if [ -z " $ASSIGN_TS " ] || [ " $ASSIGN_TS " = " null " ] ; then
159+ echo " [WARN] No assignment event found for issue # $ISSUE . Skipping."
141160 continue
142161 fi
143162
@@ -148,24 +167,17 @@ echo "$ALL_ISSUES_JSON" | jq -c '.' | while read -r ISSUE_JSON; do
148167 echo " [INFO] Days since assignment: $DIFF_DAYS "
149168
150169 # Check if any open PRs are linked to this issue
151- PR_NUMBERS=$( gh api \
152- -H " Accept: application/vnd.github.mockingbird-preview+json" \
153- " repos/$REPO /issues/$ISSUE /timeline" \
154- --jq " .[]
155- | select(.event == \" cross-referenced\" )
156- | select(.source.issue.pull_request != null)
157- | .source.issue.number" 2> /dev/null || true)
158-
159- OPEN_PR_FOUND=" "
160- if [ -n " $PR_NUMBERS " ]; then
161- for PR_NUM in $PR_NUMBERS ; do
162- PR_STATE=$( gh pr view " $PR_NUM " --repo " $REPO " --json state --jq ' .state' 2> /dev/null || true)
163- if [ " $PR_STATE " = " OPEN" ]; then
164- OPEN_PR_FOUND=" $PR_NUM "
165- break
166- fi
167- done
168- fi
170+ OPEN_PR_FOUND=$( gh api graphql -f query="
171+ query {
172+ repository(owner: \" ${REPO%/* } \" , name: \" ${REPO#*/ } \" ) {
173+ issue(number: $ISSUE ) {
174+ closedByPullRequestsReferences(first: 100, includeClosedPrs: false) {
175+ nodes { number state }
176+ }
177+ }
178+ }
179+ }
180+ " --jq ' [.data.repository.issue.closedByPullRequestsReferences.nodes[] | select(.state == "OPEN") | .number] | first // empty' 2>&1 ) || true
169181
170182 if [ -n " $OPEN_PR_FOUND " ]; then
171183 echo " [KEEP] An OPEN PR #$OPEN_PR_FOUND is linked to this issue → skip reminder."
0 commit comments