Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
784c5dab
Commit
784c5dab
authored
May 26, 2021
by
Jonas Waelter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace 'tags' with 'topics' association on project
Changelog: removed
parent
733f5040
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
13 additions
and
23 deletions
+13
-23
app/controllers/dashboard/projects_controller.rb
app/controllers/dashboard/projects_controller.rb
+1
-1
app/models/project.rb
app/models/project.rb
+3
-7
lib/api/entities/basic_project_details.rb
lib/api/entities/basic_project_details.rb
+5
-5
lib/api/entities/project.rb
lib/api/entities/project.rb
+4
-4
spec/lib/gitlab/import_export/all_models.yml
spec/lib/gitlab/import_export/all_models.yml
+0
-1
spec/models/project_spec.rb
spec/models/project_spec.rb
+0
-5
No files found.
app/controllers/dashboard/projects_controller.rb
View file @
784c5dab
...
...
@@ -36,7 +36,7 @@ class Dashboard::ProjectsController < Dashboard::ApplicationController
# rubocop: disable CodeReuse/ActiveRecord
def
starred
@projects
=
load_projects
(
params
.
merge
(
starred:
true
))
.
includes
(
:forked_from_project
,
:t
ag
s
)
.
includes
(
:forked_from_project
,
:t
opic
s
)
@groups
=
[]
...
...
app/models/project.rb
View file @
784c5dab
...
...
@@ -127,14 +127,10 @@ class Project < ApplicationRecord
after_create
:check_repository_absence!
acts_as_ordered_taggable_on
:topics
# The 'tag_list' alias
and the 'tags' association are
required during the 'tags -> topics' migration
# TODO: eliminate 'tag_list'
and 'tags'
in the further process of the migration
# The 'tag_list' alias
is
required during the 'tags -> topics' migration
# TODO: eliminate 'tag_list' in the further process of the migration
# https://gitlab.com/gitlab-org/gitlab/-/issues/328226
alias_attribute
:tag_list
,
:topic_list
has_many
:tags
,
->
{
order
(
"
#{
ActsAsTaggableOn
::
Tagging
.
table_name
}
.id"
)
},
class_name:
'ActsAsTaggableOn::Tag'
,
through: :topic_taggings
,
source: :tag
attr_accessor
:old_path_with_namespace
attr_accessor
:template_name
...
...
@@ -637,7 +633,7 @@ class Project < ApplicationRecord
mount_uploader
:bfg_object_map
,
AttachmentUploader
def
self
.
with_api_entity_associations
preload
(
:project_feature
,
:route
,
:t
ag
s
,
:group
,
:timelogs
,
namespace:
[
:route
,
:owner
])
preload
(
:project_feature
,
:route
,
:t
opic
s
,
:group
,
:timelogs
,
namespace:
[
:route
,
:owner
])
end
def
self
.
with_web_entity_associations
...
...
lib/api/entities/basic_project_details.rb
View file @
784c5dab
...
...
@@ -38,12 +38,12 @@ module API
# rubocop: disable CodeReuse/ActiveRecord
def
self
.
preload_relation
(
projects_relation
,
options
=
{})
# Preloading topics, should be done with using only `:t
ag
s`,
# as `:t
ags` are defined as: `has_many :tag
s, through: :taggings`
# N+1 is solved then by using `subject.t
ag
s.map(&:name)`
# Preloading topics, should be done with using only `:t
opic
s`,
# as `:t
opics` are defined as: `has_many :topic
s, through: :taggings`
# N+1 is solved then by using `subject.t
opic
s.map(&:name)`
# MR describing the solution: https://gitlab.com/gitlab-org/gitlab-foss/merge_requests/20555
projects_relation
.
preload
(
:project_feature
,
:route
)
.
preload
(
:import_state
,
:t
ag
s
)
.
preload
(
:import_state
,
:t
opic
s
)
.
preload
(
:auto_devops
)
.
preload
(
namespace:
[
:route
,
:owner
])
end
...
...
@@ -58,7 +58,7 @@ module API
# through the database, it will trigger a new query, ending up
# in an N+1 if we have several projects
strong_memoize
(
:topic_names
)
do
project
.
t
ag
s
.
pluck
(
:name
).
sort
# rubocop:disable CodeReuse/ActiveRecord
project
.
t
opic
s
.
pluck
(
:name
).
sort
# rubocop:disable CodeReuse/ActiveRecord
end
end
end
...
...
lib/api/entities/project.rb
View file @
784c5dab
...
...
@@ -123,9 +123,9 @@ module API
# rubocop: disable CodeReuse/ActiveRecord
def
self
.
preload_relation
(
projects_relation
,
options
=
{})
# Preloading t
ags, should be done with using only `:tag
s`,
# as `:t
ags` are defined as: `has_many :tag
s, through: :taggings`
# N+1 is solved then by using `subject.t
ag
s.map(&:name)`
# Preloading t
opics, should be done with using only `:topic
s`,
# as `:t
opics` are defined as: `has_many :topic
s, through: :taggings`
# N+1 is solved then by using `subject.t
opic
s.map(&:name)`
# MR describing the solution: https://gitlab.com/gitlab-org/gitlab-foss/merge_requests/20555
super
(
projects_relation
).
preload
(
group: :namespace_settings
)
.
preload
(
:ci_cd_settings
)
...
...
@@ -136,7 +136,7 @@ module API
.
preload
(
project_group_links:
{
group: :route
},
fork_network: :root_project
,
fork_network_member: :forked_from_project
,
forked_from_project:
[
:route
,
:t
ag
s
,
:group
,
:project_feature
,
namespace:
[
:route
,
:owner
]])
forked_from_project:
[
:route
,
:t
opic
s
,
:group
,
:project_feature
,
namespace:
[
:route
,
:owner
]])
end
# rubocop: enable CodeReuse/ActiveRecord
...
...
spec/lib/gitlab/import_export/all_models.yml
View file @
784c5dab
...
...
@@ -345,7 +345,6 @@ project:
-
external_approval_rules
-
taggings
-
base_tags
-
tags
-
topic_taggings
-
topics
-
chat_services
...
...
spec/models/project_spec.rb
View file @
784c5dab
...
...
@@ -6930,11 +6930,6 @@ RSpec.describe Project, factory_default: :keep do
it
'tag_list returns correct string array'
do
expect
(
project
.
tag_list
).
to
match_array
(
%w[topic1 topic2 topic3]
)
end
it
'tags returns correct tag records'
do
expect
(
project
.
tags
.
first
.
class
.
name
).
to
eq
(
'ActsAsTaggableOn::Tag'
)
expect
(
project
.
tags
.
map
(
&
:name
)).
to
match_array
(
%w[topic1 topic2 topic3]
)
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment