-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Adding support for Counting bugs by issue type bug #8430
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Adding support for Counting bugs by issue type bug #8430
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR!
@@ -49,7 +51,7 @@ const bugs = new CachedFunction('bugs', { | |||
|
|||
async function getSearchQueryBugLabel(): Promise<string> { | |||
const {label} = await bugs.getCached() ?? {}; | |||
return 'label:' + SearchQuery.escapeValue(label ?? 'bug'); | |||
return `(label:${label ?? 'bug'} OR type:Bug)`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't drop the escape
@@ -24,20 +24,22 @@ type Bugs = { | |||
async function countBugs(): Promise<Bugs> { | |||
const {repository} = await api.v4(CountBugs); | |||
|
|||
const issuesBugCount = repository.issues.totalCount ?? 0; | |||
|
|||
// Prefer native "bug" label |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you simplify this setup? I'd rather see:
const label = repository.labels.find( etc ) ?? 'bug'
const count = repository.labels.find( etc ) ?? 0
return {label, count: count + issuesBugCount}
@@ -24,20 +24,22 @@ type Bugs = { | |||
async function countBugs(): Promise<Bugs> { | |||
const {repository} = await api.v4(CountBugs); | |||
|
|||
const issuesBugCount = repository.issues.totalCount ?? 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const issuesBugCount = repository.issues.totalCount ?? 0; | |
const bugTypeCount = repository.issues.totalCount ?? 0; |
@@ -1,4 +1,4 @@ | |||
const queryPartsRegExp = /(?:[^\s"]|"[^"]*")+/g; | |||
const queryPartsRegExp = /[^\s"()]+:[^"\s()]*(?:"[^"]*")?|\([^)]*\)|"[^"]*"|[^\s"():]+/g; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oof this is a mouthful. Would be good to add more tests with and without parents to see how it behaves
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the regex isn't beautiful, I'll add tests for different cases en scenarios!
Of course, I'll take a look at all your suggestions in the coming week! |
Closes #8227
Not the best at crafting regexp, so would appreciate suggestions on how to improve it if possible, but all existing tests on queryPartsRegExp are still passing.
Test URLs
https://github.com/refined-github/refined-github/issues?q=sort%3Aupdated-desc+is%3Aissue+is%3Aopen+%28label%3Abug+OR+type%3ABug%29
Unfortunately don't have any public repository available to test the issue type bug on.
Screenshot