Commit 8315f363 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'feature/reset_event_cache' of /home/git/repositories/gitlab/gitlabhq

parents ffb0ad93 99eefcb5
...@@ -423,6 +423,7 @@ class Project < ActiveRecord::Base ...@@ -423,6 +423,7 @@ class Project < ActiveRecord::Base
gitlab_shell.rm_satellites(old_path_with_namespace) gitlab_shell.rm_satellites(old_path_with_namespace)
ensure_satellite_exists ensure_satellite_exists
send_move_instructions send_move_instructions
reset_events_cache
rescue rescue
# Returning false does not rollback after_* transaction but gives # Returning false does not rollback after_* transaction but gives
# us information about failing some of tasks # us information about failing some of tasks
...@@ -434,4 +435,19 @@ class Project < ActiveRecord::Base ...@@ -434,4 +435,19 @@ class Project < ActiveRecord::Base
raise Exception.new('repository cannot be renamed') raise Exception.new('repository cannot be renamed')
end end
end end
# Reset events cache related to this project
#
# Since we do cache @event we need to reset cache in special cases:
# * when project was moved
# * when project was renamed
# Events cache stored like events/23-20130109142513.
# The cache key includes updated_at timestamp.
# Thus it will automatically generate a new fragment
# when the event is updated because the key changes.
def reset_events_cache
Event.where(project_id: self.id).
order('id DESC').limit(100).
update_all(updated_at: Time.now)
end
end end
...@@ -32,6 +32,9 @@ class ProjectTransferService ...@@ -32,6 +32,9 @@ class ProjectTransferService
# create satellite repo # create satellite repo
project.ensure_satellite_exists project.ensure_satellite_exists
# clear project cached events
project.reset_events_cache
true true
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