merge: emoji search show closest match first (#351)

Fixes #338
This commit is contained in:
Marie 2024-01-12 20:27:01 +01:00
commit b20425b736
2 changed files with 4 additions and 3 deletions

View File

@ -98,11 +98,12 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
}
if (ps.query) {
q.andWhere('emoji.name like :query', { query: '%' + sqlLikeEscape(ps.query) + '%' });
q.andWhere('emoji.name like :query', { query: '%' + sqlLikeEscape(ps.query) + '%' })
.orderBy('length(emoji.name)', 'ASC');
}
const emojis = await q
.orderBy('emoji.id', 'DESC')
.addOrderBy('emoji.id', 'DESC')
.limit(ps.limit)
.getMany();

View File

@ -91,7 +91,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
//q.andWhere('emoji.name ILIKE :q', { q: `%${ sqlLikeEscape(ps.query) }%` });
//const emojis = await q.limit(ps.limit).getMany();
emojis = await q.getMany();
emojis = await q.orderBy('length(emoji.name)', 'ASC').getMany();
const queryarry = ps.query.match(/\:([a-z0-9_]*)\:/g);
if (queryarry) {