Skip to content

Eliminate redundant GitHub API calls in bot commands #6

Description

@chenhaot

Several bot commands (cmd_issues, cmd_suggest, cmd_prs) call github.list_issues(repo, include_prs=True) which fetches up to 30 items from the GitHub API, then filters client-side. When both /issues and /suggest are called, or when the scheduler runs _check_issues and _send_suggestions back-to-back (both are scheduled to run immediately on startup at scheduler.py:175-176), the same issues are fetched multiple times within seconds.

More critically, cmd_prs at bot.py:120 calls list_issues(repo, include_prs=True) and filters for PRs, but there's already a dedicated list_prs() function in github.py that uses the pulls API endpoint which is more appropriate and returns PR-specific fields like branch name.

Fix: Use github.list_prs() in cmd_prs instead of list_issues. Consider adding a simple time-based cache (e.g., functools.lru_cache with TTL or a manual cache dict) to list_issues to avoid redundant API calls within short windows.


Identified by minbot code review

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions