Perf: Optimize issue polling with GraphQL to fix N+1 calls#84
Perf: Optimize issue polling with GraphQL to fix N+1 calls#84
Conversation
This change replaces the N+1 REST API calls in `poll_issues` with a single GraphQL query that fetches all updated issues and their latest notes in one request. This significantly reduces the number of API calls made during polling. Changes: - Implemented `send_graphql_request` and `get_issues_with_notes_graphql` in `GitlabApiClient`. - Added GraphQL response models in `src/models.rs`. - Refactored `poll_issues` in `src/polling.rs` to use the GraphQL client. - Added `parse_gid` helper function to handle GraphQL Global IDs. - Exposed `poll_issues` and `poll_merge_requests` as `pub(crate)` for testing. - Added `src/tests/polling_optimization_test.rs` to verify the optimization and prevent regression. Co-authored-by: myaple <10523487+myaple@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
fix the pipeline fails and fix merge conflicts with main |
I have merged |
- Optimized issue polling by replacing N+1 REST calls with a single GraphQL query. - Merged changes from `main` and resolved conflicts in `src/polling.rs`. - Fixed unused variable warning. - Added `get_issues_with_notes_graphql` and `parse_gid`. - Added new test `src/tests/polling_optimization_test.rs`. Co-authored-by: myaple <10523487+myaple@users.noreply.github.com>
Implemented a performance optimization for issue polling by switching from N+1 REST API calls (fetch issues, then fetch notes for each issue) to a single GraphQL query that fetches issues and their notes together.
Key changes:
src/gitlab.rs: Addedget_issues_with_notes_graphqlusingsend_graphql_request.src/models.rs: Added GraphQL response structs (GraphqlIssue,GraphqlNote, etc.).src/polling.rs: Rewrotepoll_issuesto use the new GraphQL method. Addedparse_gidto convert GraphQL GIDs to integer IDs. Exposed polling methods for testing.src/tests/polling_optimization_test.rs: Added a test case that mocks the GraphQL response and verifies that REST note endpoints are not called.The optimization reduces API calls from
1 + N(where N is the number of updated issues) to1per polling cycle per project.PR created automatically by Jules for task 103587490874014786 started by @myaple