codetriage / CodeTriage

Discover the best way to get started contributing to Open Source projects
https://www.codetriage.com
MIT License
1.38k stars 359 forks source link

Incorrect issue count #1794

Closed lauriejefferson closed 8 months ago

lauriejefferson commented 9 months ago

The issue count is not updating for a repo under "Repos you are currently helping". The screenshot below is an example of the issue count for the Spree repo that show 315 issues

Screenshot 2023-10-07 at 9 11 17 AM

but when you go to the repo, there's only 225 issues

Screenshot 2023-10-07 at 9 17 34 AM

Expected Behavior

The issues count should update to reflect the actual number of issues on the GitHub repository.

Current Behavior

The issue count is not updating to reflect the actual number of issues on the GitHub repository.

Possible Solution

Update the issue count to match the number of issues on a GitHub repository.

Steps to Reproduce (for bugs)

  1. Log onto Code Triage
  2. View repo count under "Repos you are currently helping"
Mattherix commented 8 months ago

Cause of the issue

The number of issues is the number of issues and pull requests open in the repository (225 issues + 90 pull requests = 315).

GitHub considers pull requests as issues in their api. I have gotten all their issues using the GitHub cli

# Getting all issues
$ gh api --paginate repos/spree/spree/issues | jq '.[].html_url'
"https://github.com/spree/spree/issues/11934"
"https://github.com/spree/spree/pull/11932"
[...]
# Counting all issues
$ gh api --paginate repos/spree/spree/issues | jq '.[].html_url' | wc -l
315

An example issue (spree/spree#11934)

{
  "url": "https://api.github.com/repos/spree/spree/issues/11934",
  "repository_url": "https://api.github.com/repos/spree/spree",
  "labels_url": "https://api.github.com/repos/spree/spree/issues/11934/labels{/name}",
  "comments_url": "https://api.github.com/repos/spree/spree/issues/11934/comments",
  "events_url": "https://api.github.com/repos/spree/spree/issues/11934/events",
  "html_url": "https://github.com/spree/spree/issues/11934",
  "id": 1908908596,
  "node_id": "I_kwDNDPLOcceiNA",
  "number": 11934,
  "title": "Support Rails 7.1",
  "user": {},
  "labels": [],
  "state": "open",
  "locked": false,
  "assignee": null,
  "assignees": [],
  "milestone": null,
  "comments": 0,
  "created_at": "2023-09-22T13:25:55Z",
  "updated_at": "2023-09-22T13:25:55Z",
  "closed_at": null,
  "author_association": "MEMBER",
  "active_lock_reason": null,
  "body": null,
  "reactions": {},
  "timeline_url": "https://api.github.com/repos/spree/spree/issues/11934/timeline",
  "performed_via_github_app": null,
  "state_reason": null
}

An example pull request (spree/spree#11932)

{
  "url": "https://api.github.com/repos/spree/spree/issues/11932",
  "repository_url": "https://api.github.com/repos/spree/spree",
  "labels_url": "https://api.github.com/repos/spree/spree/issues/11932/labels{/name}",
  "comments_url": "https://api.github.com/repos/spree/spree/issues/11932/comments",
  "events_url": "https://api.github.com/repos/spree/spree/issues/11932/events",
  "html_url": "https://github.com/spree/spree/pull/11932",
  "id": 1898252811,
  "node_id": "PR_kwDNDPLOWm58cg",
  "number": 11932,
  "title": "Improve line item packaging",
  "user": {},
  "labels": [],
  "state": "open",
  "locked": false,
  "assignee": null,
  "assignees": [],
  "milestone": null,
  "comments": 4,
  "created_at": "2023-09-15T11:40:56Z",
  "updated_at": "2023-10-02T09:59:02Z",
  "closed_at": null,
  "author_association": "NONE",
  "active_lock_reason": null,
  "draft": false,
  "pull_request": {
    "url": "https://api.github.com/repos/spree/spree/pulls/11932",
    "html_url": "https://github.com/spree/spree/pull/11932",
    "diff_url": "https://github.com/spree/spree/pull/11932.diff",
    "patch_url": "https://github.com/spree/spree/pull/11932.patch",
    "merged_at": null
  },
  "body": "Fixes #8621 \r\nMore context is provided in the original issue and in each commit body.",
  "reactions": {},
  "timeline_url": "https://api.github.com/repos/spree/spree/issues/11932/timeline",
  "performed_via_github_app": null,
  "state_reason": null
}

Possible solutions

[!IMPORTANT]
I do not know how to program in Ruby and have not tested these solutions, so take them with a grain of salt.

Maybe we could filter the list of issues by checking that the "pull_request" field does not exist while counting. https://github.com/codetriage/CodeTriage/blob/a86e568030ff0639a798f0f52735182ad961ad58/app/models/repo.rb#L146-L151

We could also filter while fetching the API (See https://stackoverflow.com/a/66348538/1336930)

If this is a desired behavior, maybe we should change the card and replace "Issue" by "Issue & PR" https://github.com/codetriage/CodeTriage/blob/a86e568030ff0639a798f0f52735182ad961ad58/app/views/repos/_repo.html.slim#L1-L8

lauriejefferson commented 8 months ago

@Mattherix I thought that maybe there was a mistake in the issue count, but from the above code I can see how its being calculated.

schneems commented 8 months ago

Github used to classify PRs as issues with code attached. It's how I still think about them. We have the info to separate out PRs. I think that's how most newer developers would think about them

Changing the UI is always tricky. We don't have any long term maintainers that are "visual/frontend" folks. That would be my biggest hesitation to adding this info to the UI: Need to iterate on visuals.