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
ea6e0b81
Commit
ea6e0b81
authored
Dec 07, 2021
by
Furkan Ayhan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Apply reviewer feedbacks
parent
052dfa05
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
15 additions
and
9 deletions
+15
-9
app/models/ci/namespace_mirror.rb
app/models/ci/namespace_mirror.rb
+5
-5
app/models/namespace.rb
app/models/namespace.rb
+1
-0
app/models/project.rb
app/models/project.rb
+1
-0
app/services/ci/process_sync_events_service.rb
app/services/ci/process_sync_events_service.rb
+2
-2
spec/lib/gitlab/import_export/all_models.yml
spec/lib/gitlab/import_export/all_models.yml
+2
-0
spec/models/ci/namespace_mirror_spec.rb
spec/models/ci/namespace_mirror_spec.rb
+1
-1
spec/models/user_spec.rb
spec/models/user_spec.rb
+3
-1
No files found.
app/models/ci/namespace_mirror.rb
View file @
ea6e0b81
...
...
@@ -6,9 +6,9 @@ module Ci
class
NamespaceMirror
<
ApplicationRecord
belongs_to
:namespace
scope
:contains_namespace
s
,
->
(
ids
)
{
where
(
'traversal_ids @> ARRAY[?]::int[]'
,
id
s
.
join
(
','
)
)
}
scope
:contains_namespace
,
->
(
id
)
do
where
(
'traversal_ids @> ARRAY[?]::int[]'
,
id
)
end
class
<<
self
def
sync!
(
event
)
...
...
@@ -25,10 +25,10 @@ module Ci
private
def
sync_children_namespaces!
(
namespace_id
,
traversal_ids
)
contains_namespace
s
([
namespace_id
]
)
contains_namespace
(
namespace_id
)
.
where
.
not
(
namespace_id:
namespace_id
)
.
update_all
(
"traversal_ids = ARRAY[
#{
traversal_ids
.
join
(
','
)
}
]::int[] || traversal_ids[array_position(traversal_ids,
#{
namespace_id
}
) + 1:]"
"traversal_ids = ARRAY[
#{
sanitize_sql
(
traversal_ids
.
join
(
','
))
}
]::int[] || traversal_ids[array_position(traversal_ids,
#{
sanitize_sql
(
namespace_id
)
}
) + 1:]"
)
end
end
...
...
app/models/namespace.rb
View file @
ea6e0b81
...
...
@@ -619,6 +619,7 @@ class Namespace < ApplicationRecord
path_changed?
&&
!
project_namespace?
end
# SyncEvents are created by PG triggers (with the function `insert_namespaces_sync_event`)
def
schedule_sync_event_worker
run_after_commit
do
Namespaces
::
SyncEvent
.
enqueue_worker
...
...
app/models/project.rb
View file @
ea6e0b81
...
...
@@ -2938,6 +2938,7 @@ class Project < ApplicationRecord
project_namespace
.
visibility_level
=
visibility_level
end
# SyncEvents are created by PG triggers (with the function `insert_projects_sync_event`)
def
schedule_sync_event_worker
run_after_commit
do
Projects
::
SyncEvent
.
enqueue_worker
...
...
app/services/ci/process_sync_events_service.rb
View file @
ea6e0b81
...
...
@@ -29,8 +29,8 @@ module Ci
return
if
events
.
empty?
min
=
events
[
0
]
max
=
events
[
-
1
]
min
=
events
.
first
max
=
events
.
last
events
.
each
{
|
event
|
@sync_class
.
sync!
(
event
)
}
@sync_event_class
.
for_id
(
min
.
id
..
max
.
id
).
delete_all
...
...
spec/lib/gitlab/import_export/all_models.yml
View file @
ea6e0b81
...
...
@@ -597,6 +597,8 @@ project:
-
security_scans
-
ci_feature_usages
-
bulk_import_exports
-
ci_project_mirror
-
sync_events
award_emoji
:
-
awardable
-
user
...
...
spec/models/ci/namespace_mirror_spec.rb
View file @
ea6e0b81
...
...
@@ -9,7 +9,7 @@ RSpec.describe Ci::NamespaceMirror do
let!
(
:group4
)
{
create
(
:group
,
parent:
group3
)
}
describe
'.sync!'
do
let!
(
:event
)
{
Namespaces
::
SyncEvent
.
create!
(
namespace:
namespace
)
}
let!
(
:event
)
{
namespace
.
sync_events
.
create!
}
subject
(
:sync
)
{
described_class
.
sync!
(
event
.
reload
)
}
...
...
spec/models/user_spec.rb
View file @
ea6e0b81
...
...
@@ -1540,7 +1540,9 @@ RSpec.describe User do
allow
(
user
).
to
receive
(
:update_highest_role
)
end
allow
(
SecureRandom
).
to
receive
(
:hex
).
and_return
(
'3b8ca303'
)
# Namespace#schedule_sync_event_worker => Sidekiq calls `SecureRandom.hex(12)` to generate `jid`
expect
(
SecureRandom
).
to
receive
(
:hex
).
with
(
12
).
and_call_original
expect
(
SecureRandom
).
to
receive
(
:hex
).
with
(
no_args
).
and_return
(
'3b8ca303'
)
user
=
create
(
:user
)
...
...
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