Project

General

Profile

Extending the Query Model

Added by ciaran jessup about 14 years ago

We've been implementing an in-house extension to the Query model (may OS it, but its very bespoke so not yet sure if it would be worthwhile.) Its a voting plugin that introduces a 'has_one' relationship between issue and ballot (i.e. issue has_one ballot, and ballot belongs_to issue).

Everything works and is fine and dandy, but our Query patch is a bit squiffy :(

We've happily used method_aliases to sort out the 'available_filters', the 'sql_for_field' and 'issues' methods, but in order to complete the work we've had to fully replace the 'issue_count_by_group' and 'issue_count' with out own (identical) methods to introduce our new 'ballot' table into the 'includes' section of the Issue.find_all (etc.) method calls.

Clearly this works, but is pretty fragile, it is also liable to interfere with other plugins that may want to do the same thing. Have we missed something or should there be an optional 'options[:include]' type argument available to these count methods in the same way as there is in the 'issues' method.

I'm happy to provide a patch to redmine's Query.rb if it helps, althought I imagine it would take longer to apply the patch provided than it would to do the change to the core code manually ;)


Replies (1)

RE: Extending the Query Model - Added by Felix Schäfer about 14 years ago

I haven't read all, but it seems you're trying the same thing as the voting plugin already does, any particular reason for not using that one?

    (1-1/1)