code: def experiment_duration_chart(request, project_id):
      try:
          # Get the filter parameters from the request
          params = request.query_params
          tag = None
  
          if "tag" in params:
              tag = str(params["tag"])
  
              tag_query = """
  select distinct value as tag
  from modelchimp_experiment ml,
  jsonb_array_elements(ml.durations::jsonb -> 'tag_list')
  where project_id = %s
          	"""
  
              tag_query = tag_query % (project_id,)
              tag_query_result = execute_query(tag_query)
              tag_query_result = [
                  tag["tag"] for tag in tag_query_result
              ]
              if tag not in tag_query_result:
                  raise ValueError("Duration tag does not exist")
      except Exception as e:
          return Response(
              "Error: %s" % e, status=status.HTTP_400_BAD_REQUEST
          )
  
      query = """
  select
  	id,
      name,
      short_name,
  	sum(value::decimal) as value
  from (select
        id,
        name,
        CASE WHEN name = experiment_id THEN SUBSTRING(name,0,8)
          ELSE name
          END as short_name,
        value ->> 'epoch' as epoch,
        value ->> 'value' as value
  from modelchimp_experiment ml,
  json_array_elements(ml.durations::json -> 'duration' -> '%s')
  where project_id = %s ) a
  group by id, name, short_name
  	"""
  
      query = query % (
          tag,
          project_id,
      )
  
      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 3 for calling a global function with example usage: experiment_duration_chart(request, project_id) and returns: Response, Response