diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2019-04-08 15:33:36 +0200 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2019-04-15 13:05:14 +0200 |
commit | 650f40865e5d8136cb366fbde689c4100aafb0c5 (patch) | |
tree | f740d9f235693ad8e2a3693d6ec30dee26d2a74a /app/services | |
parent | 7457c1e1229cd1e90e608e8b247e2fbb217f05b6 (diff) | |
download | gitlab-ce-650f40865e5d8136cb366fbde689c4100aafb0c5.tar.gz |
Forbid the use of `#reload` and prefer `#reset`forbid-the-usage-of-reload
The `#reload` makes to load all objects into memory,
and the main purpose of `#reload` is to drop the association cache.
The `#reset` seems to solve exactly that case.
Diffstat (limited to 'app/services')
7 files changed, 9 insertions, 9 deletions
diff --git a/app/services/groups/destroy_service.rb b/app/services/groups/destroy_service.rb index 641111aeadc..654fe84e3dc 100644 --- a/app/services/groups/destroy_service.rb +++ b/app/services/groups/destroy_service.rb @@ -20,7 +20,7 @@ module Groups end # reload the relation to prevent triggering destroy hooks on the projects again - group.projects.reload + group.projects.reset group.children.each do |group| # This needs to be synchronous since the namespace gets destroyed below diff --git a/app/services/notes/update_service.rb b/app/services/notes/update_service.rb index d2052bed646..384d1dd2e50 100644 --- a/app/services/notes/update_service.rb +++ b/app/services/notes/update_service.rb @@ -22,7 +22,7 @@ module Notes # We need to refresh the previous suggestions call cache # in order to get the new records. - note.reload + note.reset end note diff --git a/app/services/projects/detect_repository_languages_service.rb b/app/services/projects/detect_repository_languages_service.rb index b020e4d9088..d3680637217 100644 --- a/app/services/projects/detect_repository_languages_service.rb +++ b/app/services/projects/detect_repository_languages_service.rb @@ -29,7 +29,7 @@ module Projects set_detected_repository_languages end - project.repository_languages.reload + project.repository_languages.reset end # rubocop: enable CodeReuse/ActiveRecord diff --git a/app/services/projects/move_project_group_links_service.rb b/app/services/projects/move_project_group_links_service.rb index 36afcd0c503..cf4b291c761 100644 --- a/app/services/projects/move_project_group_links_service.rb +++ b/app/services/projects/move_project_group_links_service.rb @@ -26,7 +26,7 @@ module Projects # Remove remaining project group links from source_project def remove_remaining_project_group_links - source_project.reload.project_group_links.destroy_all # rubocop: disable DestroyAll + source_project.reset.project_group_links.destroy_all # rubocop: disable DestroyAll end def group_links_in_target_project diff --git a/app/services/projects/transfer_service.rb b/app/services/projects/transfer_service.rb index 5da1e39a1fb..97ca00b2ea5 100644 --- a/app/services/projects/transfer_service.rb +++ b/app/services/projects/transfer_service.rb @@ -30,7 +30,7 @@ module Projects true rescue Projects::TransferService::TransferError => ex - project.reload + project.reset project.errors.add(:new_namespace, ex.message) false end @@ -122,7 +122,7 @@ module Projects def rollback_side_effects rollback_folder_move - project.reload + project.reset update_namespace_and_visibility(@old_namespace) update_repository_configuration(@old_path) end diff --git a/app/services/users/migrate_to_ghost_user_service.rb b/app/services/users/migrate_to_ghost_user_service.rb index 04fd6e37501..a66b6627e40 100644 --- a/app/services/users/migrate_to_ghost_user_service.rb +++ b/app/services/users/migrate_to_ghost_user_service.rb @@ -33,7 +33,7 @@ module Users end end - user.reload + user.reset end private diff --git a/app/services/users/refresh_authorized_projects_service.rb b/app/services/users/refresh_authorized_projects_service.rb index fe5a82e23fa..4a26d2be2af 100644 --- a/app/services/users/refresh_authorized_projects_service.rb +++ b/app/services/users/refresh_authorized_projects_service.rb @@ -25,7 +25,7 @@ module Users # We need an up to date User object that has access to all relations that # may have been created earlier. The only way to ensure this is to reload # the User object. - user.reload + user.reset end def execute @@ -84,7 +84,7 @@ module Users # Since we batch insert authorization rows, Rails' associations may get # out of sync. As such we force a reload of the User object. - user.reload + user.reset end def fresh_access_levels_per_project |