[Vtigercrm-developers] adding sorting to QueryGenerator

Adam Heinz amh at metricwise.net
Tue Jun 26 12:19:04 PDT 2012


I have a feature request in to allow sorting on related names, i.e.
pull up a list of quotes, then sort on the name of the related
contact.  After staring at the code for a bit, I have a plan of
attack, but it modifies QueryGenerator, so I want to make sure the
ticket I open for this can get into vTiger trunk.

The QueryGenerator does not currently attempt to join against the
related tables.  If you trace the logic through ListView and
ListViewController, you eventually end up at
http://trac.vtiger.com/cgi-bin/trac.cgi/browser/vtigercrm/branches/5.4.0/include/utils/CommonUtils.php#L3021,
which takes the contactids and gets their names separately.  Since
we've only retrieved a single page of results, we have no opportunity
to sort the greater result set.

So obviously joining against another large table is a performance
concern (even if it is against the primary key), so these changes
would need to be optional.  That said, I think it would be fairly
straightforward to add a column to the result, aliasing it to
contactid_ref for easy lookups and collision avoidance.  A related
short term hack would be to copy the *_ref values into the list view
controller's nameList member, so that very little other code needs to
be touched.

Opinions?


More information about the vtigercrm-developers mailing list