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

Add feature to search through factoids within Discord. #23

Merged
merged 17 commits into from
Sep 11, 2021

Conversation

randomairborne
Copy link
Contributor

@randomairborne randomairborne commented Aug 19, 2021

This pull request implements a function to search through the factoids using keywords, for example !?s adwcleaner would return all factoids with the word adwcleaner somewhere in the name or contents. If there are more then factoids.max (default 5) results, then they will be paginated and you can access other pages by typing in their page number at the end, like !?s hosts 2 for the second page of results for hosts. Queries must be at least 3 characters to prevent spam by getting every factoid with the letter A.

This would mostly help on mobile, where accessing the website is not feasible or not performant.

Also resolves #8 and obsoletes #2

@randomairborne
Copy link
Contributor Author

Because i absolutely suck at git, this also resolves #8

@LordRalex
Copy link
Owner

I 100% prefer that we fix the panel over adding workarounds. If the panel has problems, those should be addressed over adding a new command to Absol to replace it.

modules/mcping/mcping.go Outdated Show resolved Hide resolved
modules/search/search.go Outdated Show resolved Hide resolved
modules/search/search.go Show resolved Hide resolved
modules/search/search.go Outdated Show resolved Hide resolved
modules/search/search.go Show resolved Hide resolved
modules/search/search.go Outdated Show resolved Hide resolved
modules/search/search.go Outdated Show resolved Hide resolved
modules/search/search.go Outdated Show resolved Hide resolved
@randomairborne
Copy link
Contributor Author

randomairborne commented Aug 20, 2021

I think there are two problems with using the panel on mobile- one being that the panel is slow on mobile, but the other (and bigger) problem is that it's hard to switch between Discord and a browser (i.e. the panel) on mobile, which is made more severe by the fact that the panel is slow.

@LordRalex
Copy link
Owner

one being that the panel is slow on mobile

Every time I see this, I see it's the same speed on phone and desktop. I don't see it being slower on a phone than a computer. It's not fast, but it's not like it's faster on your desktop than phone. And it's not slower than switching to any channel, typing a search in, looking at the results (with paging) to find the one you want.

but the other (and bigger) problem is that it's hard to switch between Discord and a browser (i.e. the panel) on mobile,

What phones make it hard? Most phones make it easy to change between apps, even a lot faster than changing between Discord channels. I don't see this as a problem, rather a refusal to use it.

modules/search/search.go Outdated Show resolved Hide resolved
modules/search/search.go Outdated Show resolved Hide resolved
@randomairborne
Copy link
Contributor Author

randomairborne commented Aug 20, 2021

You might want to talk to Boxersteavee#9999 as they're the user that has mostly been concerned about this.
I've found it annoying to switch between them on my iPad, as discord often completely reloads whenever i switch apps.

@randomairborne
Copy link
Contributor Author

see MinecraftHopper/panel#38

@randomairborne
Copy link
Contributor Author

i've tested every feature i can to the extent of my abilites, so i think its done

modules/search/search.go Outdated Show resolved Hide resolved
modules/search/search.go Outdated Show resolved Hide resolved
modules/search/search.go Outdated Show resolved Hide resolved
modules/mcping/mcping.go Show resolved Hide resolved
modules/mcping/mcping.go Outdated Show resolved Hide resolved
db.Where("content LIKE ? OR name LIKE ?", "%"+strings.Join(args, " ")+"%", "%"+strings.Join(args, " ")+"%").Table("factoids").Count(&rows) // this is a different query anyway so it just needs to be a seperate line to get the total number of results

// ensures that page number is valid
if pageNumber < 0 || pageNumber > int(rows)/max+1 {
Copy link
Owner

Choose a reason for hiding this comment

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

Just puke the last page, we already did heavy work on this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know how this would be done, as it would rely on knowing the count before the find, and that's not possible without doing the aforementioned heavy computing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's very simple to just throw the first page back at them, i'll add something to do that

modules/search/search.go Outdated Show resolved Hide resolved
modules/search/search.go Outdated Show resolved Hide resolved
modules/search/search.go Outdated Show resolved Hide resolved
@LordRalex LordRalex merged commit c86ca82 into LordRalex:master Sep 11, 2021
@randomairborne randomairborne mentioned this pull request Sep 11, 2021
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.

Add !mcping command
2 participants