Welcome to mirror list, hosted at ThFree Co, Russian Federation.

resource.rb « catalog « ci « models « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: bb4584aacae4bf4d23dc76d92044c498e7dac10a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# frozen_string_literal: true

module Ci
  module Catalog
    # This class represents a CI/CD Catalog resource.
    # A Catalog resource is normally associated to a project.
    # This model connects to the `main` database because of its
    # dependency on the Project model and its need to join with that table
    # in order to generate the CI/CD catalog.
    class Resource < ::ApplicationRecord
      self.table_name = 'catalog_resources'

      belongs_to :project

      scope :for_projects, ->(project_ids) { where(project_id: project_ids) }

      delegate :avatar_path, :description, :name, to: :project

      def versions
        project.releases.order_released_desc
      end

      def latest_version
        versions.first
      end
    end
  end
end