Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

Pixxle
Copy link

@Pixxle Pixxle commented May 3, 2025

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

image image

@Pixxle Pixxle marked this pull request as ready for review May 3, 2025 15:26
Copy link
Member

@fregante fregante left a 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)`;
Copy link
Member

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
Copy link
Member

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;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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;
Copy link
Member

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

Copy link
Author

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!

@Pixxle
Copy link
Author

Pixxle commented May 4, 2025

Thank you for the PR!

Of course, I'll take a look at all your suggestions in the coming week!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Support for Github Issue Types in bugs-tab
2 participants