Skip to content

Conversation

@feloy
Copy link

@feloy feloy commented Oct 4, 2025

Add support for excludeDrafts and onlyDrafts for GitHub Issues service

Fixes #11286

@github-actions
Copy link
Contributor

github-actions bot commented Oct 4, 2025

Messages
📖 ✨ Thanks for your contribution to Shields, @feloy!

Generated by 🚫 dangerJS against 30837c4

@feloy feloy marked this pull request as draft October 4, 2025 09:27
@feloy feloy marked this pull request as ready for review October 4, 2025 10:02
Copy link
Member

@jNullj jNullj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @feloy and thank you for contributing a solution. I gave the changes a quick look.
I have a few questions about some of these changes, just to make sure to understand what change is being done and why.

import { GithubAuthV4Service } from './github-auth-service.js'
import { documentation, transformErrors } from './github-helpers.js'

const issueCountSchema = Joi.object({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you seem to remove this schema while keeping the request for this later, why is it removed?

totalCount
}
}
search(query: $query, type: ISSUE) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did we replace repository queries with search? I have a few concerns i want to clear
Will it cost more of our rate limit?
Does search have limitations for results we might need to consider?

Also, we already have the GitHub issue custom search badge, Can we make reuse of it's code for a smaller code, should we?

Copy link
Author

@feloy feloy Oct 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did we replace repository queries with search? I have a few concerns i want to clear

I didn't find any way to filter on draft flag with the repository query. Only the search one supports it as far as I have found in the doc.

Will it cost more of our rate limit?

I have made a few tests with adding { ratelimit { cost } } in the query (https://docs.github.com/en/graphql/overview/rate-limits-and-query-limits-for-the-graphql-api#returning-the-point-value-of-a-query), and I obtain a cost of 1 in any case, with the repository or the search query.

Does search have limitations for results we might need to consider?

I cannot think of any. search seems much more flexile than repoitory

If you prefer, we can limit the changes for the previously supported requests (without draft), to still use the repository query, and switch to the search query only when a draft-related parameter is specified. What do you think?

Also, we already have the GitHub issue custom search badge, Can we make reuse of it's code for a smaller code, should we?

I'm not sure. Using search here is an implementation detail, someone may find a better solution, and it would be more difficult to decouple from the other one in my opinion

})

t.create('GitHub closed pull requests excluding drafts')
.get('/issues-pr-closed/badges/shields.json?excludeDrafts=true')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to explicitly add a true value, including the query param will assume true value.

Suggested change
.get('/issues-pr-closed/badges/shields.json?excludeDrafts=true')
.get('/issues-pr-closed/badges/shields.json?excludeDrafts')

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason I don't understand, this is failing with this change. I'm getting this error when testing:

at IcedFrisbyNock._expectField (file:///shields/core/service-test-runner/icedfrisby-shields.js:85:51)
      at IcedFrisbyNock.<anonymous> (file:///shields/core/service-test-runner/icedfrisby-shields.js:69:26)
      at IcedFrisbyNock.<anonymous> (node_modules/icedfrisby/lib/icedfrisby.js:954:10)
      at invokeNextHook (node_modules/icedfrisby/lib/icedfrisby.js:1003:24)
      at /shields/node_modules/icedfrisby/lib/icedfrisby.js:1017:7
      at new Promise (<anonymous>)
      at IcedFrisbyNock._runHooks (node_modules/icedfrisby/lib/icedfrisby.js:976:12)
      at IcedFrisbyNock.run (node_modules/icedfrisby/lib/icedfrisby.js:1276:20)
      at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
      at async Context.<anonymous> (node_modules/icedfrisby/lib/icedfrisby.js:1348:9)

@PyvesB PyvesB added the service-badge New or updated service badge label Oct 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

service-badge New or updated service badge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Option to exclude drafts from PR counts

3 participants