Improve user searching
Improve searching in mod.gg/userlookup.
- allow searching for users with just 1 or 2 letter usernames?

- fix searching result not including user who surely exists

-
That's probably a good idea, but we should make sure this isn't gonna put too much load on the DB or anything, trying to query that large of a resultset.
-
The issue here is that the list is limited to only the first 10 matches. There's definitely a match for "ther#6028", it's just sorted farther down, so you don't see it. And the only way you could further qualify the search would be by adding a "#", which the search algorithm doesn't support. For this, we should A) add support for discriminator searching, whether by specifying it via "#", or with a separate search box, and B) probably have the results sorted by match rank, which is something the database should support natively as part of its text search API. Dunno if this would be directly supported in EF.
B) probably have the results sorted by match rank, which is something the database should support natively as part of its text search API. Dunno if this would be directly supported in EF.
A rudimentary solution would be to check both the equivalent of Contains() and StartsWith() in the query, and sort by StartsWith first. Shouldn't be too much more expensive but could be difficult to express in EF.
.Where(...)
.Select(user => new
{
StartsWith = user.Username.StartsWith(query),
Model = ModixUser.FromIGuildUser(user)
})
.OrderByDescending(x => x.StartsWith)
.Take(10)
.Select(x => x.Model);
should be enough (and its compilable by EF)
Addendum...
.OrderByDescending(x => x.StartsWith)
.ThenBy(x => x.Model.Username)
As part of a new effort to refocus on priorities, I will close this. If you feel this is imperative to the bot, a new issue can be opened to supersede this.