Skip to content

[GitHubIssues] Support excludeDrafts and onlyDrafts#11401

Open
feloy wants to merge 4 commits intobadges:masterfrom
feloy:feat/exclude-drafts-on-master
Open

[GitHubIssues] Support excludeDrafts and onlyDrafts#11401
feloy wants to merge 4 commits intobadges:masterfrom
feloy:feat/exclude-drafts-on-master

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

Copy link
Member

Choose a reason for hiding this comment

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

Thank you for the detailed response, sorry for taking so long to reply.
I think we are good on using search here as the cost is similar, if in the future we see we can save up using a condition for which api call to make we can use a follow up pr.

please also see the new comments regarding simplifying this by separation of PR and issues.

})

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)

Copy link
Member

Choose a reason for hiding this comment

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

I believe the schema would need to change as well: excludeDrafts: Joi.equal('')

@PyvesB PyvesB added the service-badge New or updated service badge label Oct 5, 2025
Co-authored-by: jNullj <15849761+jNullj@users.noreply.github.com>
@PyvesB
Copy link
Member

PyvesB commented Dec 26, 2025

One thing I'm wondering is whether draft issues are even a thing? If not, I don't think we should be introducing options or terminology (i.e. draft issues) that don't make sense from a user perspective. These badges are complex-enough as they are.

Perhaps the way forward here would be to split the GitHubIssues badges in two, GitHubIssues and GitHubPullRequests:

  • GitHubIssues would stay as it is today, holding the issues, issues-raw, issues-closed, and issues-closed-raw variants. It would rely on the existing repository query.
  • GitHubPullRequests would hold the issues-pr, issues-pr-raw, issues-pr-closed, and issues-pr-closed-raw variants, as well as the new excludeDrafts and onlyDrafts options. It would rely on the new search query for all cases.

@jNullj
Copy link
Member

jNullj commented Dec 29, 2025

That makes a lot of sense to me.
@feloy does that sound reasonable? This is a bit of a change from the original contribution.

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

Development

Successfully merging this pull request may close these issues.

Option to exclude drafts from PR counts

3 participants