Code review comment for lp:~adeuring/launchpad/bug-512500-searchtasks-patch-age-sort

Revision history for this message
Abel Deuring (adeuring) wrote :

We want to sort bug tasks on "age of youngest patch".
While this is in general possible without this new column,
implementing it in Storm is at least quite cumbersome,
if possible at all, as discussed on IRC.

Bug attachments and bugs have n:1 relationship, so we
would have to use a SELECT DISTINCT ON() clause in order
to find te youngest patch attached to a bug --
unfortunately, a DISTINCT ON clause is not available for
Storm. We could use a very lengthy GROUP BY clause instead,
but it would not look very nice.

The main problem with a "plain qury implementation" is though
that we need a sub-select to find the youngest patch and
the related data from the tables Bug and BugTask, and that
we would have to use a query like

SELECT * FROM (sub-select) ORDER BY latest_patch_uploaded

in order to sort the result set. Unfortunately, Storm does not
seem to allow to use sub-select in this way. While sub-select
can be used like store.find(table, sub-select), the sub-select
parameter would be used for a WHERE clause, but not as the
"data source" for the main select.

As discussed on IRC, it seems that creating a redundant
column Bug.latest_patch_uploaded is at present more or less
reasonable, considering the difficulties with Storm.

« Back to merge proposal