code: def experiment_metric_filter(request, project_id):
      try:
          # Get the filter parameters from the request
          params = request.query_params
  
          if "param" in params:
              param = str(params["param"])
  
              param_query = """
  select distinct json_object_keys(parameters::json) as param
  from modelchimp_experiment ml
  where json_typeof(parameters::json) = 'object'
  and project_id = %s
          	"""
  
              param_query = param_query % (project_id,)
              param_query_result = execute_query(param_query)
              param_query_result = [
                  pqr["param"] for pqr in param_query_result
              ]
              if param not in param_query_result:
                  raise ValueError("Model Parameter does not exist")
          else:
              param = None
      except Exception as e:
          return Response(
              "Error: %s" % e, status=status.HTTP_400_BAD_REQUEST
          )
  
      query = """
  select distinct value as metric
  from modelchimp_experiment ml,
  jsonb_array_elements(ml.metrics::jsonb -> 'metric_list')
  where project_id = %s %s
  order by metric
  	"""
  
      query = query % (
          project_id,
          "and parameters->>'%s' is not null" % (param,)
          if param
          else "",
      )
  
      result_raw = execute_query(query)
  
      return Response(result_raw, status=status.HTTP_200_OK)
  
file_path: modelchimp/modelchimp/views/api/project_dashboard.py
imports: from rest_framework import status
  from rest_framework.decorators import api_view, permission_classes
  from rest_framework.response import Response
  from modelchimp.utils.data_utils import execute_query
  from modelchimp.api_permissions import HasProjectMembership
  from rest_framework.permissions import IsAuthenticated
label_desc: Use image node_id 2 for calling a global function with example usage: experiment_metric_filter(request, project_id) and returns: Response, Response