Commit 8315f363e40a2f26e9d0b9fbdabe7d5c0603bf65
Exists in
master
and in
4 other branches
Merge branch 'feature/reset_event_cache' of /home/git/repositories/gitlab/gitlabhq
Showing
2 changed files
with
19 additions
and
0 deletions
Show diff stats
app/models/project.rb
| ... | ... | @@ -423,6 +423,7 @@ class Project < ActiveRecord::Base |
| 423 | 423 | gitlab_shell.rm_satellites(old_path_with_namespace) |
| 424 | 424 | ensure_satellite_exists |
| 425 | 425 | send_move_instructions |
| 426 | + reset_events_cache | |
| 426 | 427 | rescue |
| 427 | 428 | # Returning false does not rollback after_* transaction but gives |
| 428 | 429 | # us information about failing some of tasks |
| ... | ... | @@ -434,4 +435,19 @@ class Project < ActiveRecord::Base |
| 434 | 435 | raise Exception.new('repository cannot be renamed') |
| 435 | 436 | end |
| 436 | 437 | end |
| 438 | + | |
| 439 | + # Reset events cache related to this project | |
| 440 | + # | |
| 441 | + # Since we do cache @event we need to reset cache in special cases: | |
| 442 | + # * when project was moved | |
| 443 | + # * when project was renamed | |
| 444 | + # Events cache stored like events/23-20130109142513. | |
| 445 | + # The cache key includes updated_at timestamp. | |
| 446 | + # Thus it will automatically generate a new fragment | |
| 447 | + # when the event is updated because the key changes. | |
| 448 | + def reset_events_cache | |
| 449 | + Event.where(project_id: self.id). | |
| 450 | + order('id DESC').limit(100). | |
| 451 | + update_all(updated_at: Time.now) | |
| 452 | + end | |
| 437 | 453 | end | ... | ... |
app/services/project_transfer_service.rb