Commit e75c8bd2 authored by Yorick Peterse's avatar Yorick Peterse

Merge branch 'import-machine-improvement' into 'master'

Reduce UPDATE queries when moving between import states on projects

See merge request !723
parents 1b0e045d a855aade
Please view this file on the master branch, on stable branches it's out of date. Please view this file on the master branch, on stable branches it's out of date.
v 8.12.0 (Unreleased) v 8.12.0 (Unreleased)
- Reduce UPDATE queries when moving between import states on projects
- [ES] Instrument Elasticsearch::Git::Repository - [ES] Instrument Elasticsearch::Git::Repository
- [ES] Instrument other Gitlab::Elastic classes - [ES] Instrument other Gitlab::Elastic classes
......
...@@ -237,12 +237,11 @@ class Project < ActiveRecord::Base ...@@ -237,12 +237,11 @@ class Project < ActiveRecord::Base
after_transition any => :finished, do: :reset_cache_and_import_attrs after_transition any => :finished, do: :reset_cache_and_import_attrs
after_transition started: :finished do |project, transaction| before_transition started: :finished do |project, transaction|
if project.mirror? if project.mirror?
timestamp = DateTime.now timestamp = DateTime.now
project.mirror_last_update_at = timestamp project.mirror_last_update_at = timestamp
project.mirror_last_successful_update_at = timestamp project.mirror_last_successful_update_at = timestamp
project.save
end end
if current_application_settings.elasticsearch_indexing? if current_application_settings.elasticsearch_indexing?
...@@ -250,10 +249,8 @@ class Project < ActiveRecord::Base ...@@ -250,10 +249,8 @@ class Project < ActiveRecord::Base
end end
end end
after_transition started: :failed do |project, transaction| before_transition started: :failed do |project, transaction|
if project.mirror? project.mirror_last_update_at = DateTime.now if project.mirror?
project.update(mirror_last_update_at: DateTime.now)
end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment