Class: DeploymentMergeRequest

Inherits:
ApplicationRecord show all
Extended by:
SuppressCompositePrimaryKeyWarning
Defined in:
app/models/deployment_merge_request.rb

Constant Summary

Constants inherited from ApplicationRecord

ApplicationRecord::MAX_PLUCK

Class Method Summary collapse

Methods inherited from ApplicationRecord

cached_column_list, #create_or_load_association, declarative_enum, default_select_columns, id_in, id_not_in, iid_in, pluck_primary_key, primary_key_in, #readable_by?, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, #to_ability_name, underscore, where_exists, where_not_exists, with_fast_read_statement_timeout, without_order

Methods included from SensitiveSerializableHash

#serializable_hash

Class Method Details

.by_deployment_id(id) ⇒ Object


14
15
16
# File 'app/models/deployment_merge_request.rb', line 14

def self.by_deployment_id(id)
  where(deployments: { id: id })
end

.deployed_after(time) ⇒ Object


27
28
29
# File 'app/models/deployment_merge_request.rb', line 27

def self.deployed_after(time)
  where('deployments.finished_at > ?', time)
end

.deployed_before(time) ⇒ Object


31
32
33
# File 'app/models/deployment_merge_request.rb', line 31

def self.deployed_before(time)
  where('deployments.finished_at < ?', time)
end

.deployed_to(name) ⇒ Object


18
19
20
21
22
23
24
25
# File 'app/models/deployment_merge_request.rb', line 18

def self.deployed_to(name)
  # We filter by project ID again so the query uses the index on
  # (project_id, name), instead of using the index on
  # (name varchar_pattern_ops). This results in better performance on
  # GitLab.com.
  where(environments: { name: name })
    .where('environments.project_id = merge_requests.target_project_id')
end

.join_deployments_for_merge_requestsObject


9
10
11
12
# File 'app/models/deployment_merge_request.rb', line 9

def self.join_deployments_for_merge_requests
  joins(deployment: :environment)
    .where('deployment_merge_requests.merge_request_id = merge_requests.id')
end