Patch #2482

Named scopes in Issue and ActsAsWatchable plus some view refactoring (logic extraction).

Added by Nikos Dimitrakopoulos almost 9 years ago. Updated over 7 years ago.

Status:ClosedStart date:2009-01-09
Priority:NormalDue date:
Assignee:Eric Davis% Done:

100%

Category:Code cleanup/refactoring
Target version:1.0.0 (RC)

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 a named_scope of the same name (so no API breaking)
  • Adds Issue::recently_updated, Issue::with_limit and Issue::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
and
  • 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 :)

_redmine_-0002-Added-named-scopes-in-Issue-and-ActsAsWatchable-inst.diff Magnifier - Patch against trunk, r2250 (5.84 KB) Nikos Dimitrakopoulos, 2009-01-09 18:15

Associated revisions

Revision 3557
Added by Eric Davis over 7 years ago

Adds named scopes to replace custom finders.

  • Adds watched_by class method in ActsAsWatchable
  • Adds Issue#recently_updated, Issue#with_limit and Issue#on_active_project

    #2482

History

#1 Updated by Eric Davis almost 9 years ago

  • Assignee set to Eric Davis

I'll take a look at this patch and see about appling.

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 :)

I would find that really useful. I've been waiting for 0.8 to be released before I went through refactoring. If you use git, could you branch from my GitHub repository and send me the patches through GitHub? It makes it easy to review and apply them.

Thanks

#3 Updated by Eric Davis over 7 years ago

  • Category set to Code cleanup/refactoring
  • Status changed from 7 to Closed
  • Target version set to 1.0.0 (RC)
  • % Done changed from 0 to 100

Committed in r3557

Also available in: Atom PDF