Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
Greenlight
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Arbeitsgruppe Hardwarenahe IT-Systeme
Greenlight
Commits
e6545279
Unverified
Commit
e6545279
authored
Feb 3, 2023
by
Khemissi Amir
Committed by
GitHub
Feb 3, 2023
Browse files
Options
Downloads
Patches
Plain Diff
V3 Migrations: Optimized `Migrations::ExternalController::create_settings` API. (#4747)
parent
dc24ac9b
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/controllers/api/v1/migrations/external_controller.rb
+23
-17
23 additions, 17 deletions
app/controllers/api/v1/migrations/external_controller.rb
with
23 additions
and
17 deletions
app/controllers/api/v1/migrations/external_controller.rb
+
23
−
17
View file @
e6545279
...
@@ -146,26 +146,29 @@ module Api
...
@@ -146,26 +146,29 @@ module Api
render_data
status: :created
unless
settings_hash
.
any?
render_data
status: :created
unless
settings_hash
.
any?
# Finds all the SiteSettings that need to be updated
# Finds all the SiteSettings that need to be updated
site_settings_
temp
=
SiteSetting
.
joins
(
:setting
)
site_settings_
joined
=
SiteSetting
.
joins
(
:setting
)
.
where
(
'settings.name'
:
settings_hash
[
:site_settings
].
keys
,
provider:
'greenlight'
)
.
where
(
'settings.name'
:
settings_hash
[
:site_settings
].
keys
,
provider:
'greenlight'
)
.
pluck
(
:id
,
:'settings.name'
)
.
to_h
return
render_error
(
status: :bad_request
,
errors:
'A site setting does not exist.'
)
unless
site_settings_temp
okay
=
true
site_settings_joined
.
each
do
|
site_setting
|
site_setting_name
=
site_setting
.
setting
.
name
okay
=
false
unless
site_setting
.
update
(
value:
settings_hash
[
:site_settings
][
site_setting_name
])
end
# Re-structure the data so it is in the format: { <site_setting_id>: { value: <site_setting_new_value> } }
return
render_error
status: :bad_request
,
errors:
'Something went wrong when migrating site settings.'
unless
okay
site_settings
=
site_settings_temp
.
transform_values
{
|
v
|
{
value:
settings_hash
[
:site_settings
][
v
.
to_sym
]
}
}
SiteSetting
.
update!
(
site_settings
.
keys
,
site_settings
.
values
)
# Finds all the RoomsConfiguration that need to be updated
# Finds all the RoomsConfiguration that need to be updated
room_configurations_
temp
=
RoomsConfiguration
.
joins
(
:meeting_option
)
room_configurations_
joined
=
RoomsConfiguration
.
joins
(
:meeting_option
)
.
where
(
'meeting_options.name'
:
settings_hash
[
:room_configurations
].
keys
,
.
where
(
'meeting_options.name'
:
settings_hash
[
:room_configurations
].
keys
,
provider:
'greenlight'
)
provider:
'greenlight'
)
.
pluck
(
:id
,
:'meeting_options.name'
)
.
to_h
okay
=
true
# Re-structure the data so it is in the format: { <rooms_configuration_id>: { value: <rooms_configuration_new_value> } }
room_configurations_joined
.
each
do
|
room_configuration
|
room_configurations
=
room_configurations_temp
.
transform_values
{
|
v
|
{
value:
settings_hash
[
:room_configurations
][
v
.
to_sym
]
}
}
room_configuration_name
=
room_configuration
.
meeting_option
.
name
RoomsConfiguration
.
update!
(
room_configurations
.
keys
,
room_configurations
.
values
)
okay
=
false
unless
room_configuration
.
update
(
value:
settings_hash
[
:room_configurations
][
room_configuration_name
])
end
return
render_error
status: :bad_request
,
errors:
'Something went wrong when migrating room configurations.'
unless
okay
render_data
status: :created
render_data
status: :created
end
end
...
@@ -189,7 +192,10 @@ module Api
...
@@ -189,7 +192,10 @@ module Api
end
end
def
settings_params
def
settings_params
decrypted_params
.
require
(
:settings
).
permit
(
site_settings:
{},
room_configurations:
{})
decrypted_params
.
require
(
:settings
).
permit
(
site_settings:
%w[PrimaryColor PrimaryColorLight Terms PrivacyPolicy RegistrationMethod
ShareRooms PreuploadPresentation]
,
room_configurations:
%w[record muteOnStart guestPolicy glAnyoneCanStart glAnyoneJoinAsModerator
glRequireAuthentication]
)
end
end
def
decrypted_params
def
decrypted_params
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment