Class: PagesDeployment
Overview
PagesDeployment stores a zip archive containing GitLab Pages web-site
Constant Summary
collapse
- STORE_COLUMN =
:file_store
FileStoreMounter::ALLOWED_FILE_FIELDS
ApplicationRecord::MAX_PLUCK
HasCheckConstraints::NOT_NULL_CHECK_PATTERN
ResetOnColumnErrors::MAX_RESET_PERIOD
Class Method Summary
collapse
Instance Method Summary
collapse
===, cached_column_list, #create_or_load_association, current_transaction, declarative_enum, default_select_columns, delete_all_returning, #deleted_from_database?, id_in, id_not_in, iid_in, nullable_column?, 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
#sharding_organization
#reset_on_union_error, #reset_on_unknown_attribute_error
#serializable_hash
Class Method Details
.count_versioned_deployments_for(projects, limit, group_by_project: false) ⇒ Object
78
79
80
81
82
|
# File 'app/models/pages_deployment.rb', line 78
def self.count_versioned_deployments_for(projects, limit, group_by_project: false)
query = project_id_in(projects).active.versioned
query = query.group(:project_id) if group_by_project
query.limit(limit).count
end
|
.deactivate ⇒ Object
74
75
76
|
# File 'app/models/pages_deployment.rb', line 74
def self.deactivate
update(deleted_at: Time.now.utc)
end
|
.deactivate_all(project) ⇒ Object
58
59
60
61
62
63
|
# File 'app/models/pages_deployment.rb', line 58
def self.deactivate_all(project)
now = Time.now.utc
active
.project_id_in(project.id)
.update_all(updated_at: now, deleted_at: now)
end
|
.deactivate_deployments_older_than(deployment, time: nil) ⇒ Object
65
66
67
68
69
70
71
72
|
# File 'app/models/pages_deployment.rb', line 65
def self.deactivate_deployments_older_than(deployment, time: nil)
now = Time.now.utc
active
.older_than(deployment.id)
.project_id_in(deployment.project_id)
.with_path_prefix(deployment.path_prefix)
.update_all(updated_at: now, deleted_at: time || now)
end
|
.declarative_policy_class ⇒ Object
50
51
52
|
# File 'app/models/pages_deployment.rb', line 50
def self.declarative_policy_class
'Pages::DeploymentPolicy'
end
|
.latest_pipeline_id ⇒ Object
54
55
56
|
# File 'app/models/pages_deployment.rb', line 54
def self.latest_pipeline_id
Ci::Build.id_in(pluck(:ci_build_id)).maximum(:commit_id)
end
|
Instance Method Details
#active? ⇒ Boolean
84
85
86
|
# File 'app/models/pages_deployment.rb', line 84
def active?
deleted_at.nil?
end
|
#deactivate ⇒ Object
94
95
96
|
# File 'app/models/pages_deployment.rb', line 94
def deactivate
update_attribute(:deleted_at, Time.now.utc)
end
|
#restore ⇒ Object
98
99
100
101
|
# File 'app/models/pages_deployment.rb', line 98
def restore
update_attribute(:deleted_at, nil)
deactivate_deployments_with_same_path_prefix
end
|
#url ⇒ Object
88
89
90
91
92
|
# File 'app/models/pages_deployment.rb', line 88
def url
::Gitlab::Pages::UrlBuilder
.new(project, { path_prefix: path_prefix.to_s })
.pages_url
end
|