mirror of
				https://codeberg.org/yeentown/barkey.git
				synced 2025-11-04 07:24:13 +00:00 
			
		
		
		
	emoji search: show closest match first #338
This commit is contained in:
		
							parent
							
								
									bbdc4e7789
								
							
						
					
					
						commit
						d2d75b25bf
					
				
					 2 changed files with 4 additions and 3 deletions
				
			
		| 
						 | 
				
			
			@ -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();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue