Skip to content
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

feat(discussions): refactor get_discussions function for pagination support #433

Conversation

Jalmeida1994
Copy link
Contributor

@Jalmeida1994 Jalmeida1994 commented Nov 27, 2024

Pull Request

This pull request includes enhancements to the get_discussions function in discussions.py to support pagination and improvements to the corresponding tests in test_discussions.py. The most important changes include adding pagination to the GraphQL query, handling pagination in the function, and updating the tests to cover these scenarios.

Closes #44

Proposed Changes

  • Add pagination support to GitHub Discussions Query.

Respective Issue: #44

Readiness Checklist

Author/Contributor

  • If documentation is needed for this change, has that been included in this pull request
  • run make lint and fix any issues that you have introduced
  • run make test and ensure you have test coverage for the lines you are introducing
  • If publishing new data to the public (scorecards, security scan results, code quality results, live dashboards, etc.), please request review from @jeffrey-luszcz

Reviewer

  • Label as either fix, documentation, enhancement, infrastructure, maintenance, or breaking

Choose a reason for hiding this comment

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated no suggestions.

Copy link
Member

@zkoppert zkoppert left a comment

Choose a reason for hiding this comment

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

Hey! Thanks for contributing this! Have you been able to test this out locally? Can you post the results for a a run on an open source repo?

@Jalmeida1994
Copy link
Contributor Author

Hey @zkoppert, how are you?

Thanks for the review! I've tested this with both GitHub Enterprise Server (GHES) and public GitHub repositories to ensure the pagination works correctly across different environments.

Here are the results from testing against the GitHub CLI's discussion repository (cli/cli):

SEARCH_QUERY = "repo:cli/cli type:discussions created:2022-10-31..2024-10-31"

The script successfully processed 283 total discussions:

$ python3 issue_metrics.py 
Starting issue-metrics search...
Average time to first response: 3 days, 5:30:50
Time to close: 18 days, 1:09:56
Average time to answer: 8 days, 4:01:42
Wrote issue metrics to issue_metrics.md
# Discussion Metrics Report

| Metric | Average | Median | 90th percentile |
| --- | --- | --- | ---: |
| Time to first response | 3 days, 5:30:50 | 8:11:30 | 5 days, 18:12:07 |
| Time to close | 18 days, 1:09:56 | 6:14:52 | 22 days, 13:37:09 |
| Time to answer | 8 days, 4:01:42 | 18:12:44 | 12 days, 21:03:25 |

| Metric | Count |
| --- | ---: |
| Number of items that remain open | 237 |
| Number of items closed | 46 |
| Number of most active mentors | 0 |
| Total number of items created | 283 |

| Title | URL | Author | Time to first response | Time to close | Time to answer |
| --- | --- | --- | --- | --- | --- |
| Failing to authenticate on new wsl setup | https://github.com/cli/cli/discussions/6884 | [None](https://github.com/None) | 5:06:12 | None | None |
| How to ‘push’ with gh? | https://github.com/cli/cli/discussions/6889 | [None](https://github.com/None) | 1:09:47 | None | 1:32:20 |
| Issue with Cloning Repository Using GitHub CLI | https://github.com/cli/cli/discussions/9796 | [None](https://github.com/None) | 0:08:56 | 21 days, 22:52:23 | 22 days, 21:52:18 |
| What is the order of filtering operations for search? | https://github.com/cli/cli/discussions/9750 | [None](https://github.com/None) | 8 days, 1:29:17 | 29 days, 2:29:54 | None |
| gh repo create: when adding a team, the granted permission is "read"? | https://github.com/cli/cli/discussions/6906 | [None](https://github.com/None) | 17:53:14 | None | None |

(truncated)

| Issue GH CLI Auth with Jenkins | https://github.com/cli/cli/discussions/6604 | [None](https://github.com/None) | 6:39:41 | None | None |
| GitHub CLI 2.20.0 | https://github.com/cli/cli/discussions/6585 | [None](https://github.com/None) | 2 days, 17:42:43 | None | None |
| GitHub CLI 2.19.0 | https://github.com/cli/cli/discussions/6561 | [None](https://github.com/None) | None | None | None |

_This report was generated with the [Issue Metrics Action](https://github.com/github/issue-metrics)_
Search query used to find these items: `repo:cli/cli type:discussions created:2022-10-31..2024-10-31`

I've included a truncated result, but let me know if you want the full output.

Let me know if you'd like me to test against any other repositories or if you need any additional information!

Copy link
Member

@zkoppert zkoppert left a comment

Choose a reason for hiding this comment

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

Fantastic! Thank you!!

@zkoppert zkoppert merged commit 2a4bfcb into github:main Dec 1, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Discussions are limited to 100 results
2 participants