parameters: (request:HttpRequest, project_id=None)
return_statement: return JsonResponse(dict(cursor.fetchall()))
docstring: Find mappings to existing skeletons for potential imports.
      ---
      parameters:
        - name: project_id
          description: Project to operate in
          type: integer
          paramType: path
          required: true
        - name: source_ids[]
          description: IDs of the source IDs to query origin for
          required: true
          type: array
          items:
            type: integer
          paramType: form
        - name: source_url
          description: Source URL of skeletons
          type: string
          paramType: path
          required: true
        - name: source_project_id
          description: Source project ID of skeletons
          type: integer
          paramType: path
          required: true
docstring_summary: Find mappings to existing skeletons for potential imports.
      ---
      parameters:
        - name: project_id
          description: Project to operate in
          type: integer
          paramType: path
          required: true
        - name: source_ids[]
          description: IDs of the source IDs to query origin for
          required: true
          type: array
          items:
            type: integer
          paramType: form
        - name: source_url
          description: Source URL of skeletons
          type: string
          paramType: path
          required: true
        - name: source_project_id
          description: Source project ID of skeletons
          type: integer
          paramType: path
          required: true
docstring_tokens: Find mappings to existing skeletons for potential imports . --- parameters : - name : project_id description : Project to operate in type : integer paramType : path required : true - name : source_ids [] description : IDs of the source IDs to query origin for required : true type : array items : type : integer paramType : form - name : source_url description : Source URL of skeletons type : string paramType : path required : true - name : source_project_id description : Source project ID of skeletons type : integer paramType : path required : true
function: def from_origin(request:HttpRequest, project_id=None) -> JsonResponse:
      """Find mappings to existing skeletons for potential imports.
      ---
      parameters:
        - name: project_id
          description: Project to operate in
          type: integer
          paramType: path
          required: true
        - name: source_ids[]
          description: IDs of the source IDs to query origin for
          required: true
          type: array
          items:
            type: integer
          paramType: form
        - name: source_url
          description: Source URL of skeletons
          type: string
          paramType: path
          required: true
        - name: source_project_id
          description: Source project ID of skeletons
          type: integer
          paramType: path
          required: true
      """
  
      if request.method == 'GET':
          data = request.GET
      elif request.method == 'POST':
          data = request.POST
      else:
          raise ValueError("Invalid HTTP method: " + request.method)
  
      source_ids = get_request_list(data, 'source_ids', map_fn=int)
      if not source_ids:
          raise ValueError('Need at least one source ID')
  
      source_url = data.get('source_url')
      if not source_url:
          raise ValueError('Need source_url for origin lookup')
      source_url = normalize_source_url(source_url)
  
      source_project_id = data.get('source_project_id')
      if source_project_id is None:
          raise ValueError("Need source_project_id for origin lookup")
  
      cursor = connection.cursor()
      cursor.execute("""
          SELECT so.source_id, so.skeleton_id
          FROM skeleton_origin so
          JOIN UNNEST(%(source_ids)s::bigint[]) query(source_id)
              ON query.source_id = so.source_id
          JOIN data_source ds
              ON ds.id = so.data_source_id
          WHERE so.project_id = %(project_id)s
              AND ds.project_id = %(project_id)s
              AND ds.url = %(source_url)s
              AND ds.source_project_id = %(source_project_id)s
      """, {
          'source_ids': source_ids,
          'project_id': project_id,
          'source_url': source_url,
          'source_project_id': source_project_id,
      })
  
      return JsonResponse(dict(cursor.fetchall()))
function_tokens: def from_origin ( request : HttpRequest , project_id = None ) -> JsonResponse : if request . method == 'GET' : data = request . GET elif request . method == 'POST' : data = request . POST else : raise ValueError ( "Invalid HTTP method: " + request . method ) source_ids = get_request_list ( data , 'source_ids' , map_fn = int ) if not source_ids : raise ValueError ( 'Need at least one source ID' ) source_url = data . get ( 'source_url' ) if not source_url : raise ValueError ( 'Need source_url for origin lookup' ) source_url = normalize_source_url ( source_url ) source_project_id = data . get ( 'source_project_id' ) if source_project_id is None : raise ValueError ( "Need source_project_id for origin lookup" ) cursor = connection . cursor ( ) cursor . execute ( """
          SELECT so.source_id, so.skeleton_id
          FROM skeleton_origin so
          JOIN UNNEST(%(source_ids)s::bigint[]) query(source_id)
              ON query.source_id = so.source_id
          JOIN data_source ds
              ON ds.id = so.data_source_id
          WHERE so.project_id = %(project_id)s
              AND ds.project_id = %(project_id)s
              AND ds.url = %(source_url)s
              AND ds.source_project_id = %(source_project_id)s
      """ , { 'source_ids' : source_ids , 'project_id' : project_id , 'source_url' : source_url , 'source_project_id' : source_project_id , } ) return JsonResponse ( dict ( cursor . fetchall ( ) ) )