def get(self, request, group): # optional queryparam `key` can be used to get results # only for specific keys. keys = [tagstore.prefix_reserved_key(k) for k in request.GET.getlist('key') if k] or None # There are 2 use-cases for this method. For the 'Tags' tab we # get the top 10 values, for the tag distribution bars we get 9 # This should ideally just be specified by the client if keys: value_limit = 9 else: value_limit = 10 try: environment_id = self._get_environment_id_from_request( request, group.project.organization_id) except Environment.DoesNotExist: tag_keys = [] else: tag_keys = tagstore.get_group_tag_keys_and_top_values( group.project_id, group.id, environment_id, keys=keys, value_limit=value_limit) return Response(serialize(tag_keys, request.user))
def get(self, request, group): # optional queryparam `key` can be used to get results # only for specific keys. keys = [ tagstore.prefix_reserved_key(k) for k in request.GET.getlist('key') if k ] or None # There are 2 use-cases for this method. For the 'Tags' tab we # get the top 10 values, for the tag distribution bars we get 9 # This should ideally just be specified by the client if keys: value_limit = 9 else: value_limit = 10 try: environment_id = self._get_environment_id_from_request( request, group.project.organization_id) except Environment.DoesNotExist: tag_keys = [] else: tag_keys = tagstore.get_group_tag_keys_and_top_values( group.project_id, group.id, environment_id and [environment_id], keys=keys, value_limit=value_limit) return Response(serialize(tag_keys, request.user))
def get(self, request: Request, group) -> Response: # optional queryparam `key` can be used to get results # only for specific keys. keys = [ tagstore.prefix_reserved_key(k) for k in request.GET.getlist("key") if k ] or None # There are 2 use-cases for this method. For the 'Tags' tab we # get the top 10 values, for the tag distribution bars we get 9 # This should ideally just be specified by the client if keys: value_limit = 9 else: value_limit = 10 environment_ids = [ e.id for e in get_environments(request, group.project.organization) ] tag_keys = tagstore.get_group_tag_keys_and_top_values( group.project_id, group.id, environment_ids, keys=keys, value_limit=value_limit) return Response(serialize(tag_keys, request.user))
def get(self, request, group): # optional queryparam `key` can be used to get results # only for specific keys. keys = [tagstore.prefix_reserved_key(k) for k in request.GET.getlist('key') if k] or None # There are 2 use-cases for this method. For the 'Tags' tab we # get the top 10 values, for the tag distribution bars we get 9 # This should ideally just be specified by the client if keys: value_limit = 9 else: value_limit = 10 use_snuba = request.GET.get('enable_snuba') == '1' environment_ids = [e.id for e in get_environments(request, group.project.organization)] if not use_snuba: # TODO(jess): This is just to ensure we're not breaking the old # issue page somehow -- non-snuba tagstore versions will raise # if more than one env is passed if environment_ids: environment_ids = environment_ids[:1] tag_keys = tagstore.get_group_tag_keys_and_top_values( group.project_id, group.id, environment_ids, keys=keys, value_limit=value_limit) return Response(serialize(tag_keys, request.user))
def get(self, request, group): try: environment_id = self._get_environment_id_from_request( request, group.project.organization_id) except Environment.DoesNotExist: data = [] else: data = tagstore.get_group_tag_keys_and_top_values( group.project_id, group.id, environment_id) return Response(data)
def get(self, request, organization): try: snuba_args = self.get_snuba_query_args(request, organization) except OrganizationEventsError as exc: return Response({'detail': exc.message}, status=400) except NoProjects: return Response({'detail': 'A valid project must be included.'}, status=400) lookup_keys = [] non_tag_lookup_keys = [] for key in request.GET.getlist('keys'): if key in self.NON_TAG_KEYS: non_tag_lookup_keys.append(key) lookup_keys.append(tagstore.prefix_reserved_key(key)) if not lookup_keys: return Response({'detail': 'Tag keys must be specified.'}, status=400) project_ids = snuba_args['filter_keys']['project_id'] environment_ids = snuba_args['filter_keys'].get('environment_id') has_global_views = features.has('organizations:global-views', organization, actor=request.user) if not has_global_views and len(project_ids) > 1: return Response( {'detail': 'You cannot view events from multiple projects.'}, status=400) try: tag_keys = tagstore.get_group_tag_keys_and_top_values( project_ids, None, environment_ids, keys=lookup_keys, get_excluded_tags=True, **snuba_args) except tagstore.TagKeyNotFound: raise ResourceDoesNotExist if non_tag_lookup_keys: tag_keys.update( self.handle_non_tag_keys(non_tag_lookup_keys, snuba_args)) return Response(serialize(tag_keys, request.user))