Skip to content

⚡ Optimize stale issue check to avoid N+1 API calls#78

Merged
myaple merged 2 commits intomainfrom
optimize-stale-issue-check-14568367117634142612
Feb 13, 2026
Merged

⚡ Optimize stale issue check to avoid N+1 API calls#78
myaple merged 2 commits intomainfrom
optimize-stale-issue-check-14568367117634142612

Conversation

@myaple
Copy link
Owner

@myaple myaple commented Feb 11, 2026

This PR optimizes the check_stale_issues function in src/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_at timestamp 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_at timestamp in GitLab. Therefore, if updated_at is old, it guarantees that no recent notes exist.

The PR also includes:

  • A new test src/tests/polling_perf_test.rs that asserts 0 API calls for notes when an issue is stale.
  • A fix for src/tests/polling_tests.rs where 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

- 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>
@google-labs-jules
Copy link
Contributor

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@myaple
Copy link
Owner Author

myaple commented Feb 12, 2026

fix the failing pipeline

@google-labs-jules
Copy link
Contributor

fix the failing pipeline

I've run cargo fmt to fix the formatting issues that caused the pipeline to fail. I also verified the tests and clippy checks pass.

Run `cargo fmt` to address pipeline failure.
Validated with `cargo clippy` and `cargo test`.

Co-authored-by: myaple <10523487+myaple@users.noreply.github.com>
@myaple myaple merged commit 4b7e66e into main Feb 13, 2026
3 checks passed
@myaple myaple deleted the optimize-stale-issue-check-14568367117634142612 branch February 13, 2026 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant