Actions
Patch #2482
closedNamed scopes in Issue and ActsAsWatchable plus some view refactoring (logic extraction).
Status:
Closed
Priority:
Normal
Assignee:
Category:
Code cleanup/refactoring
Target version:
Start date:
2009-01-09
Due date:
% Done:
100%
Estimated time:
Description
Added named_scope in Issue and ActsAsWatchable replacing custom finder method declarations in model classes and custom find queries in views.
More specifically this patch introduces the following changes:
- Replaces
watched_by
class method in ActsAsWatchable with anamed_scope
of the same name (so no API breaking) - Adds
Issue::recently_updated
,Issue::with_limit
andIssue::on_active_project
which are optional but handy. If they seem reduntant they can be removed and update the views accordingly (see next bullet) - Removes DB logic from partial view
my/blocks/_issueswatched.rhtml
which falls back to new named scopes. It would be even better if this thing was inside the controller (that is the right place) but because of the modularity of my/page (due to the blocks) I didn't touch it.
plus:
- Tests for introduced changes
- Minor documentation for introduced changes
Patch is against trunk r2250.
Note: If you find it useful I could also refactor other parts of redmine, replacing custom finders with named scopes (if possible) and extracting model logic from views. Just let me know, or simply apply this patch :)
Files
Actions