diff options
author | Mark Chao <mchao@gitlab.com> | 2018-10-01 11:02:38 +0800 |
---|---|---|
committer | Mark Chao <mchao@gitlab.com> | 2018-11-05 20:09:11 +0800 |
commit | 666ddec9b209d795ee315d1ea896feb04c30e048 (patch) | |
tree | de0206dd2cae6817fb0b76388098a9664e27766a /app | |
parent | c4bcb3a92ad6adb1acc76f337660d755e9db5409 (diff) | |
download | gitlab-ce-666ddec9b209d795ee315d1ea896feb04c30e048.tar.gz |
Combine two updates in one query
Diffstat (limited to 'app')
-rw-r--r-- | app/models/project.rb | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index fa995b5b061..08315606711 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -95,8 +95,7 @@ class Project < ActiveRecord::Base unless: :ci_cd_settings, if: proc { ProjectCiCdSetting.available? } - after_create :set_last_activity_at - after_create :set_last_repository_updated_at + after_create :set_timestamps_for_create after_update :update_forks_visibility_level before_destroy :remove_private_deploy_keys @@ -2102,13 +2101,8 @@ class Project < ActiveRecord::Base gitlab_shell.exists?(repository_storage, "#{disk_path}.git") end - # set last_activity_at to the same as created_at - def set_last_activity_at - update_column(:last_activity_at, self.created_at) - end - - def set_last_repository_updated_at - update_column(:last_repository_updated_at, self.created_at) + def set_timestamps_for_create + update_columns(last_activity_at: self.created_at, last_repository_updated_at: self.created_at) end def cross_namespace_reference?(from) |