Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitHub Referencing & GitHub Command #599

Closed
wants to merge 20 commits into from
Closed

Conversation

illuminator3
Copy link
Contributor

@illuminator3 illuminator3 commented Oct 2, 2022

unknown
image
image

changes gistApiKey to githubApiKey in the config

Tais993 and others added 4 commits September 30, 2022 23:48
In BotCore:
Added onCommandAutoCompleteInteraction listener, this way autocompletion events will actually get forwarded.

Funny, didnt think of this during the previous PR, was probably too hasty.
@illuminator3 illuminator3 requested review from a team as code owners October 2, 2022 21:40
@Tais993
Copy link
Member

Tais993 commented Oct 2, 2022

I LOVE YOU ILLU

@Taz03
Copy link
Member

Taz03 commented Oct 2, 2022

what about not having the ping when the bot replies back?

@illuminator3
Copy link
Contributor Author

what about not having the ping when the bot replies back?

why?

@Taz03
Copy link
Member

Taz03 commented Oct 2, 2022

why?

coz its a bot reply

@illuminator3
Copy link
Contributor Author

why?

coz its a bot reply

@Tais993 what do you think?

@Tais993
Copy link
Member

Tais993 commented Oct 2, 2022

Don't have an opinion, either is fine to me

@illuminator3
Copy link
Contributor Author

I'll remove it since the command usage also has no ping I guess

@illuminator3 illuminator3 self-assigned this Oct 3, 2022
@illuminator3 illuminator3 added enhancement New feature or request priority: low valid This issue/PR is validated and ready to be picked. This auto adds items to TJ project board. labels Oct 3, 2022
@Zabuzard
Copy link
Member

Zabuzard commented Oct 4, 2022

changes gistApiKey to githubApiKey in the config

note that this requires that people update their api key settings. gonna mention that when merging this.

if (title.isEmpty()) {
event.replyChoiceStrings(autocompleteCache.stream().limit(25).toList()).queue();
} else {
Queue<String> queue = new PriorityQueue<>(Comparator.comparingInt(
Copy link
Member

Choose a reason for hiding this comment

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

the name isnt really optimal. maybe closestMatches or closestSuggestions.

it also reads a bit complex since u nested everything. i would at least move out the 25-list into a variable:

Queue<String> closestMatches = ...
List<String> suggestions = ...

event.replyChoiceStrings(suggestions).queue();

maybe also the logic u use to compute the score. So that its Comparator.comparingInt(this::scoreSuggestion) or similar.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Member

Choose a reason for hiding this comment

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

could u also move the Stream.generate(closestSuggestions::poll).limit(25).toList() into its own variable? Its a bit harder to read when its all packed together with the JDA stuff of message-sending.

*/
private List<GHRepository> repositories;

public GitHubReference(Config config) {
Copy link
Member

Choose a reason for hiding this comment

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

better, yes. but i still have problems with the term "reference" for this (see other discussion). maybe we can find a better word that has less confusion potential

}

/**
* Looks through all of the given repositories for an issue/pr with the given id
Copy link
Member

Choose a reason for hiding this comment

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

missing dot

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Member

Choose a reason for hiding this comment

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

seems u forgot to push this one

String title = event.getOption(TITLE_OPTION).getAsString();

if (title.isEmpty()) {
event.replyChoiceStrings(autocompleteGHIssueCache.stream().limit(25).toList()).queue();
Copy link
Member

Choose a reason for hiding this comment

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

don't use the magic number 25 use OptionData#MAX_CHOICES instead


closestSuggestions.addAll(autocompleteGHIssueCache);

event.replyChoiceStrings(Stream.generate(closestSuggestions::poll).limit(25).toList())
Copy link
Member

Choose a reason for hiding this comment

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

don't use the magic number 25 use OptionData#MAX_CHOICES instead

@sonarqubecloud
Copy link

sonarqubecloud bot commented Oct 6, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

"helpSystem": {
"stagingChannelPattern": "ask_here",
"overviewChannelPattern": "active_questions",
"categories": [
Copy link
Member

@Zabuzard Zabuzard Oct 7, 2022

Choose a reason for hiding this comment

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

the indent for categories is one level too much

event
.replyChoiceStrings(autocompleteCache.stream()
.sorted(Comparator.comparingInt(s -> StringDistances.editDistance(title,
s.replaceFirst("\\[\\d+] ", ""))))
Copy link
Member

Choose a reason for hiding this comment

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

the method is good, thanks for that. but i would still like to have a small comment on the regex. like // Remove the ID [#123] and then match

if (title.isEmpty()) {
event.replyChoiceStrings(autocompleteCache.stream().limit(25).toList()).queue();
} else {
Queue<String> queue = new PriorityQueue<>(Comparator.comparingInt(
Copy link
Member

Choose a reason for hiding this comment

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

could u also move the Stream.generate(closestSuggestions::poll).limit(25).toList() into its own variable? Its a bit harder to read when its all packed together with the JDA stuff of message-sending.

Comment on lines +34 to +35
protected static final Pattern ISSUE_REFERENCE_PATTERN = Pattern.compile("#(?<id>\\d+)");
protected static final String ID_GROUP = "id";
Copy link
Member

Choose a reason for hiding this comment

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

gotta use the ID_GROUP in ur pattern as well. "#(?<%s>\\d+".formatted(ID_GROUP)

}

/**
* Looks through all of the given repositories for an issue/pr with the given id
Copy link
Member

Choose a reason for hiding this comment

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

seems u forgot to push this one

@Zabuzard Zabuzard added stale and removed valid This issue/PR is validated and ready to be picked. This auto adds items to TJ project board. labels Mar 6, 2023
@github-actions github-actions bot added the inactivity-closed Issues that have been closed due to inactivity, but are otherwise valid and might be reopened later label Mar 12, 2023
@github-actions github-actions bot closed this Mar 12, 2023
@illuminator3 illuminator3 added valid This issue/PR is validated and ready to be picked. This auto adds items to TJ project board. and removed inactivity-closed Issues that have been closed due to inactivity, but are otherwise valid and might be reopened later labels Mar 12, 2023
@illuminator3 illuminator3 reopened this Mar 12, 2023
@github-actions github-actions bot removed the stale label Mar 13, 2023
@Taz03 Taz03 self-assigned this Mar 16, 2023
@java-coding-prodigy
Copy link
Contributor

One year anniversary of this PR 🎉
Also are we going to this or should it be closed?

@ankitsmt211
Copy link
Member

#981 which continued work of this PR already merged.

@ankitsmt211 ankitsmt211 closed this Mar 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request priority: low valid This issue/PR is validated and ready to be picked. This auto adds items to TJ project board.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants