summaryrefslogtreecommitdiff
path: root/app/models/namespace.rb
diff options
context:
space:
mode:
authorKrasimir Angelov <kangelov@gitlab.com>2019-09-10 10:26:17 +1200
committerKrasimir Angelov <kangelov@gitlab.com>2019-09-19 12:09:36 +1200
commit7469a7726f367c5b426be18970463c6c25ed5643 (patch)
tree6854568878c9d6551c10debe308e8184b6e0f71e /app/models/namespace.rb
parenta7706bcb567ee31c6454c4197354b3210839b564 (diff)
downloadgitlab-ce-61927-pages-namespaces-virtual-domain.tar.gz
Add support for namespaces to Pages internal API61927-pages-namespaces-virtual-domain
Introduce new `project_pages_metadata` table, insert new record on project creation. Update its `depoyed` flag when pages are deployed/removed. Return only these projects from namespace that have pages marked as deployed. On-demand and mass data migration will handled in subsequent commits. Related to https://gitlab.com/gitlab-org/gitlab-ee/issues/28781.
Diffstat (limited to 'app/models/namespace.rb')
-rw-r--r--app/models/namespace.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/app/models/namespace.rb b/app/models/namespace.rb
index 9a7c3dc03c3..fb90ddc1048 100644
--- a/app/models/namespace.rb
+++ b/app/models/namespace.rb
@@ -120,6 +120,13 @@ class Namespace < ApplicationRecord
uniquify = Uniquify.new
uniquify.string(path) { |s| Namespace.find_by_path_or_name(s) }
end
+
+ def find_by_pages_host(host)
+ gitlab_host = "." + Settings.pages.host.downcase
+ name = host.downcase.delete_suffix(gitlab_host)
+
+ Namespace.find_by_full_path(name)
+ end
end
def visibility_level_field
@@ -305,8 +312,16 @@ class Namespace < ApplicationRecord
aggregation_schedule.present?
end
+ def pages_virtual_domain
+ Pages::VirtualDomain.new(all_projects_with_pages, trim_prefix: full_path)
+ end
+
private
+ def all_projects_with_pages
+ all_projects.with_pages_deployed
+ end
+
def parent_changed?
parent_id_changed?
end