⚡ Optimize stale issue check to avoid N+1 API calls#78
Conversation
- Skip fetching notes for issues that are already determined to be stale based on their `updated_at` timestamp. - This eliminates the N+1 API call problem for the majority of stale issues, significantly improving performance. - Added a new performance regression test `src/tests/polling_perf_test.rs` to verify that the API call is skipped. - Fixed an existing test case in `src/tests/polling_tests.rs` that relied on inconsistent issue state (old `updated_at` but new note), aligning it with GitLab's behavior where adding a note updates the issue timestamp. 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 failing pipeline |
I've run |
Run `cargo fmt` to address pipeline failure. Validated with `cargo clippy` and `cargo test`. Co-authored-by: myaple <10523487+myaple@users.noreply.github.com>
This PR optimizes the
check_stale_issuesfunction insrc/polling.rs.Previously, the code fetched notes for every open issue to determine staleness, causing an N+1 API call issue.
Now, it checks the issue's
updated_attimestamp first. If the issue is already older than the staleness threshold, it is considered stale immediately, and the expensive note fetch is skipped.This change is safe because adding a note updates the issue's
updated_attimestamp in GitLab. Therefore, ifupdated_atis old, it guarantees that no recent notes exist.The PR also includes:
src/tests/polling_perf_test.rsthat asserts 0 API calls for notes when an issue is stale.src/tests/polling_tests.rswhere a test case was creating an impossible state (old issue timestamp with new note), which caused a test failure with the new optimization logic. The test was updated to reflect reality.PR created automatically by Jules for task 14568367117634142612 started by @myaple