# Class: Backend::Api::Search

Inherits:
  Object
  - Object
  - Backend::Api::Search
  show all

Extended by:
  ConnectionHelper

Defined in:
  api/search.rb

## Overview

Class that connect to endpoints related to the search

## Class Method Summary collapse

- .binary(project_names, binary_name) ⇒ String

  Performs a search of the binary in a project list.

- .incident_packages(project_name, package_name, maintenance_project_name) ⇒ Object

  Performs a search of incident packages for a maintenance project.

- .packages_with_link(package_names) ⇒ Object

  Performs a search of packages with a link.

## Class Method Details

### .binary(project_names, binary_name) ⇒ `String`

Performs a search of the binary in a project list

Returns:

- (`String`)

    9
    10
    11
    12
    # File 'api/search.rb', line 9

    def self.binary(project_names, binary_name)
      project_list = project_names.map { |project_name| "@project='#{CGI.escape(project_name)}'" }.join('+or+')
      http_post("/search/published/binary/id?match=(@name='#{CGI.escape(binary_name)}'+and+(#{project_list}))")
    end

### .incident_packages(project_name, package_name, maintenance_project_name) ⇒ `Object`

Performs a search of incident packages for a maintenance project

    21
    22
    23
    24
    25
    26
    # File 'api/search.rb', line 21

    def self.incident_packages(project_name, package_name, maintenance_project_name)
      conditions = ["linkinfo/@package=\"#{CGI.escape(package_name)}\""]
      conditions << "linkinfo/@project=\"#{CGI.escape(project_name)}\""
      conditions << "starts-with(@project,\"#{CGI.escape(maintenance_project_name)}%3A\")"
      http_post("/search/package/id?match=(#{conditions.join('+and+')})")
    end

### .packages_with_link(package_names) ⇒ `Object`

Performs a search of packages with a link

    15
    16
    17
    18
    # File 'api/search.rb', line 15

    def self.packages_with_link(package_names)
      packages_list = package_names.map { |name| "linkinfo/@package='#{CGI.escape(name)}'" }.join('+or+')
      http_get("/search/package/id?match=(#{packages_list})")
    end