26
26
from sentry .api .serializers import serialize
27
27
from sentry .api .utils import handle_query_errors
28
28
from sentry .models .organization import Organization
29
+ from sentry .search .eap import constants
29
30
from sentry .search .eap .columns import translate_internal_to_public_alias
30
31
from sentry .search .eap .spans import SearchResolver
31
32
from sentry .search .eap .types import SearchResolverConfig
@@ -406,13 +407,13 @@ def __init__(
406
407
):
407
408
super ().__init__ (organization , snuba_params , key , query , max_span_tag_values )
408
409
self .resolver = SearchResolver (params = snuba_params , config = SearchResolverConfig ())
409
- self .attribute_key = self .resolve_attribute_key (key , snuba_params )
410
+ self .search_type , self . attribute_key = self .resolve_attribute_key (key , snuba_params )
410
411
411
- def resolve_attribute_key (self , key : str , snuba_params : SnubaParams ) -> AttributeKey | None :
412
+ def resolve_attribute_key (
413
+ self , key : str , snuba_params : SnubaParams
414
+ ) -> tuple [constants .SearchType , AttributeKey ]:
412
415
resolved , _ = self .resolver .resolve_attribute (key )
413
- if resolved .search_type != "string" :
414
- return None
415
- return resolved .proto_definition
416
+ return resolved .search_type , resolved .proto_definition
416
417
417
418
def execute (self ) -> list [TagValue ]:
418
419
if self .key in self .PROJECT_ID_KEYS :
@@ -421,12 +422,33 @@ def execute(self) -> list[TagValue]:
421
422
if self .key in self .PROJECT_SLUG_KEYS :
422
423
return self .project_slug_autocomplete_function ()
423
424
424
- return self .default_autocomplete_function ()
425
+ if self .search_type == "boolean" :
426
+ return self .boolean_autocomplete_function ()
425
427
426
- def default_autocomplete_function (self ) -> list [TagValue ]:
427
- if self .attribute_key is None :
428
- return []
428
+ if self .search_type == "string" :
429
+ return self .string_autocomplete_function ()
430
+
431
+ return []
432
+
433
+ def boolean_autocomplete_function (self ) -> list [TagValue ]:
434
+ return [
435
+ TagValue (
436
+ key = self .key ,
437
+ value = "false" ,
438
+ times_seen = None ,
439
+ first_seen = None ,
440
+ last_seen = None ,
441
+ ),
442
+ TagValue (
443
+ key = self .key ,
444
+ value = "true" ,
445
+ times_seen = None ,
446
+ first_seen = None ,
447
+ last_seen = None ,
448
+ ),
449
+ ]
429
450
451
+ def string_autocomplete_function (self ) -> list [TagValue ]:
430
452
start_timestamp = Timestamp ()
431
453
start_timestamp .FromDatetime (
432
454
self .snuba_params .start_date .replace (hour = 0 , minute = 0 , second = 0 , microsecond = 0 )
0 commit comments