Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
Admin
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
osuny
Admin
Commits
e3821c8f
Unverified
Commit
e3821c8f
authored
1 year ago
by
Sébastien Gaya
Browse files
Options
Downloads
Patches
Plain Diff
Research::Publication fixer
parent
8bd2c2d1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/services/fixers/research_publication_fixer.rb
+77
-0
77 additions, 0 deletions
app/services/fixers/research_publication_fixer.rb
lib/tasks/app.rake
+1
-7
1 addition, 7 deletions
lib/tasks/app.rake
with
78 additions
and
7 deletions
app/services/fixers/research_publication_fixer.rb
0 → 100644
+
77
−
0
View file @
e3821c8f
class
Fixers::ResearchPublicationFixer
def
self
.
run
# Connections
connection_ids_to_destroy
=
[]
connection_ids_to_update
=
[]
Communication
::
Website
::
Connection
.
where
(
indirect_object_type:
"Research::Hal::Publication"
).
find_each
do
|
connection
|
already_migrated_connection
=
Communication
::
Website
::
Connection
.
find_by
(
direct_source_type:
connection
.
direct_source_type
,
direct_source_id:
connection
.
direct_source_id
,
indirect_object_type:
"Research::Publication"
,
indirect_object_id:
connection
.
indirect_object_id
,
university_id:
connection
.
university_id
,
website_id:
connection
.
website_id
)
if
already_migrated_connection
.
present?
connection_ids_to_destroy
<<
connection
.
id
else
connection_ids_to_update
<<
connection
.
id
end
end
Communication
::
Website
::
Connection
.
where
(
id:
connection_ids_to_destroy
).
destroy_all
Communication
::
Website
::
Connection
.
where
(
id:
connection_ids_to_update
).
update_all
(
indirect_object_type:
"Research::Publication"
)
# Git Files
git_file_ids_to_destroy
=
[]
git_file_ids_to_update
=
[]
Communication
::
Website
::
GitFile
.
where
(
about_type:
"Research::Hal::Publication"
).
find_each
do
|
git_file
|
already_migrated_git_file
=
Communication
::
Website
::
GitFile
.
find_by
(
about_type:
"Research::Publication"
,
about_id:
git_file
.
about_id
,
website_id:
git_file
.
website_id
)
if
already_migrated_git_file
.
present?
git_file_ids_to_destroy
<<
git_file
.
id
else
git_file_ids_to_update
<<
git_file
.
id
end
end
Communication
::
Website
::
GitFile
.
where
(
id:
git_file_ids_to_destroy
).
destroy_all
Communication
::
Website
::
GitFile
.
where
(
id:
git_file_ids_to_update
).
update_all
(
about_type:
"Research::Publication"
)
# Permalinks
## Old permalinks
Communication
::
Website
::
Permalink
.
where
(
about_type:
"Research::Hal::Publication"
,
is_current:
false
).
update_all
(
about_type:
"Research::Publication"
)
permalink_ids_to_destroy
=
[]
permalink_ids_to_update
=
[]
## Current permalinks
Communication
::
Website
::
Permalink
.
where
(
about_type:
"Research::Hal::Publication"
,
is_current:
true
).
find_each
do
|
permalink
|
already_migrated_permalink
=
Communication
::
Website
::
GitFile
.
find_by
(
about_type:
"Research::Publication"
,
about_id:
permalink
.
about_id
,
website_id:
permalink
.
website_id
,
university_id:
permalink
.
university_id
,
is_current:
true
)
if
already_migrated_permalink
.
present?
permalink_ids_to_destroy
<<
permalink
.
id
else
permalink_ids_to_update
<<
permalink
.
id
end
end
Communication
::
Website
::
Permalink
.
where
(
id:
permalink_ids_to_destroy
).
destroy_all
Communication
::
Website
::
Permalink
.
where
(
id:
permalink_ids_to_update
).
update_all
(
about_type:
"Research::Publication"
)
end
end
\ No newline at end of file
This diff is collapsed.
Click to expand it.
lib/tasks/app.rake
+
1
−
7
View file @
e3821c8f
...
...
@@ -8,13 +8,7 @@ namespace :app do
desc
'Fix things'
task
fix: :environment
do
ActiveStorage
::
Attachment
.
where
(
record_type:
"Communication::Website::Category"
).
update_all
(
record_type:
"Communication::Website::Post::Category"
)
Communication
::
Block
.
where
(
about_type:
"Communication::Website::Category"
).
update_all
(
about_type:
"Communication::Website::Post::Category"
)
Communication
::
Block
::
Heading
.
where
(
about_type:
"Communication::Website::Category"
).
update_all
(
about_type:
"Communication::Website::Post::Category"
)
Communication
::
Website
::
Connection
.
where
(
direct_source_type:
"Communication::Website::Category"
).
update_all
(
direct_source_type:
"Communication::Website::Post::Category"
)
Communication
::
Website
::
GitFile
.
where
(
about_type:
"Communication::Website::Category"
).
update_all
(
about_type:
"Communication::Website::Post::Category"
)
Communication
::
Website
::
Menu
::
Item
.
where
(
about_type:
"Communication::Website::Category"
).
update_all
(
about_type:
"Communication::Website::Post::Category"
)
Communication
::
Website
::
Permalink
.
where
(
about_type:
"Communication::Website::Category"
).
update_all
(
about_type:
"Communication::Website::Post::Category"
)
Fixers
::
ResearchPublicationFixer
.
run
end
namespace
:websites
do
...
...
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