@@ -40,7 +40,7 @@ import { DBEvent, Event } from '../@types/event'
4040import { EventPurgeCounts , EventRetentionOptions , IEventRepository , IQueryResult } from '../@types/repositories'
4141import { toBuffer , toJSON } from '../utils/transform'
4242import { createLogger } from '../factories/logger-factory'
43- import { isGenericTagQuery } from '../utils/filter'
43+ import { isGenericTagQuery , isGeohashPrefixCriterion , stripGeohashPrefixWildcard } from '../utils/filter'
4444import { SubscriptionFilter } from '../@types/subscription'
4545
4646const even = pipe ( modulo ( __ , 2 ) , equals ( 0 ) )
@@ -193,8 +193,21 @@ export class EventRepository implements IEventRepository {
193193 isEmpty ,
194194 ( ) => andWhereRaw ( '1 = 0' , bd ) ,
195195 forEach (
196- ( criterion : string ) =>
197- void orWhereRaw ( 'event_tags.tag_name = ? AND event_tags.tag_value = ?' , [ filterName [ 1 ] , criterion ] , bd ) ,
196+ ( criterion : string ) => {
197+ if ( isGeohashPrefixCriterion ( filterName , criterion ) ) {
198+ return void orWhereRaw (
199+ 'event_tags.tag_name = ? AND event_tags.tag_value LIKE ?' ,
200+ [ filterName [ 1 ] , `${ stripGeohashPrefixWildcard ( criterion ) } %` ] ,
201+ bd ,
202+ )
203+ }
204+
205+ return void orWhereRaw (
206+ 'event_tags.tag_name = ? AND event_tags.tag_value = ?' ,
207+ [ filterName [ 1 ] , criterion ] ,
208+ bd ,
209+ )
210+ } ,
198211 ) ,
199212 ) ( criteria )
200213 } )
0 commit comments