Skip to content
This repository was archived by the owner on Nov 4, 2025. It is now read-only.

Conversation

@Burhan-Q
Copy link

Rationale

Brief exchange with SteveO on the docs repo made me think this could be a good addition.

Changes

Adds Discord /ref_issue command, that allows users to search for 5 relevant issues. Includes two arguments repo and query to allow specifying the repo to search and the keywords in title/topic of Issues to find.

Testing

😆 unfortunately not at all. Did my best to mirror what other sections of code were doing and to make sure it had a logical flow. Not sure if the "default" behavior included (try to search voxel51/fiftyone if no repo is specified).

Copy link
Member

@afoley587 afoley587 left a comment

Choose a reason for hiding this comment

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

How is something like?

.
.
from hata import Client, ClientWrapper, Message
.
.
.
@ALL.interactions(is_global=True, wait_for_acknowledgement=True)
async def ref_issue(client: Client, message: Message, query: ("str", "Topic to search"), repo: ("str", "Repo to search.")):  # type: ignore # noqa: F722
    """Provides specific metric(s) for the voxel51/fiftyone repository."""
    if repo is not None and repo not in VOXEL51_REPOS:
        abort("Must be Voxel51 repo.")
    elif repo is None:
        repo = "voxel51/fiftyone"  # default
    
    try:
        GITHUB.get_repo(repo)
        issues = repo.search_issues(f'{query} in:title,body')
        
        if issues.totalCount == 0:
            return await client.message_create(message.channel, "No relevant issues found.")
        
        issue_links = "\n".join(f"{issue.title}: {issue.html_url}" for issue in issues[:5])
        await client.message_create(message.channel, f"Top relevant issues:\n{issue_links}")
    
    except GithubException as e:
        logging.error(f"GitHub API error: {e}")
        await client.message_create(message.channel, "An error occurred while searching for issues. Please try again later.")

@Burhan-Q
Copy link
Author

Since I think that this will work as a slash command / (based on what I saw in the other plugins), I stuck with event and just used event.channel which I believe should be a InteractionEvent object, but to be honest, I haven't used hata before, so I'm trying to figure this out on the fly.

I added a line for fetching the GitHub organization to limit the ones that are listed. I choose to return the full_name attribute so that it would return owner/repo which should be directly compatible with the get_repo method.

@Burhan-Q
Copy link
Author

I appreciate the patience here, I've been doing a lot of this from mobile and finally had the opportunity to pull this onto a local machine. Updated with type hints, docstrings, imports, and formatting (assumed line line of 100, pylint default, since there didn't seem to be a configured value).

Added the def keyword for the function definition, and removed the redundant None checks. Also ran pre-commit locally.

I did notice that on my Windows machine, inotify-simple and cchardet failed to build. I reran without building and temporarily removing inotify-simple to install all packages, since I didn't find a "quick" solution. Not that it's critical for me at this juncture, but just wanted to point this out.

@afoley587
Copy link
Member

Great, thanks for the contribution. I will merge which will trigger a deployment.

@afoley587 afoley587 merged commit efe833d into voxel51:main Feb 20, 2025
1 check passed
@afoley587
Copy link
Member

@Burhan-Q issue with loading this plugin:

ValueError: `description` length is out of the expected range [2:100], got 104; "Returns a list of top-five related issues from a specified Voxel51 repository based on the user's query.".

@Burhan-Q
Copy link
Author

🤔 hm, guess the docstring needs shortening. Hadn't considered there would be a limit there.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants