Skip to content
Snippets Groups Projects

Adds API support for Project Deployment Frequency

Merged Amy Troschinetz requested to merge api-support-for-deployment-frequency into master
5 files
+ 94
0
Compare changes
  • Side-by-side
  • Inline
Files
5
+ 7
0
@@ -31,6 +31,7 @@ class Deployment < ApplicationRecord
delegate :name, to: :environment, prefix: true
delegate :kubernetes_namespace, to: :deployment_cluster, allow_nil: true
scope :for_project, -> (project) { where(project: project) }
scope :for_environment, -> (environment) { where(environment_id: environment) }
scope :for_environment_name, -> (name) do
joins(:environment).where(environments: { name: name })
@@ -44,6 +45,12 @@ class Deployment < ApplicationRecord
scope :older_than, -> (deployment) { where('deployments.id < ?', deployment.id) }
scope :with_deployable, -> { joins('INNER JOIN ci_builds ON ci_builds.id = deployments.deployable_id').preload(:deployable) }
scope :created_between, -> (start_date, end_date = nil) do
selected = where('deployments.created_at >= ?', start_date)
selected = where('deployments.created_at < ?', end_date) if end_date
selected
end
FINISHED_STATUSES = %i[success failed canceled].freeze
state_machine :status, initial: :created do
Loading