Multi-table buglist.cgi join from Extension.pm?

Matthew Bogosian mtb19 at columbia.edu
Mon Jan 7 01:59:22 UTC 2013


Is there a way to augment the buglist.cgi SQL query other than buglist_columns and buglist_column_joins? I want to do a multi-table join (e.g., bugs -> A -> B -> C.*), but I don't like the idea of doing the following because it seems really inefficient:

# MyExtension/Extension.pm
...
sub buglist_columns {
    my ( $self, $args ) = @_;
    my $columns = $args->{'columns'};
    $columns->{'c_val1'} = {
        'name'  => 'subquery_hack1.c_value1',
    };
    $columns->{'c_val2'} = {
        'name'  => 'subquery_hack2.c_value2',
    };
}
sub buglist_column_joins {
    my ( $self, $args ) = @_;
    my $joins = $args->{'column_joins'};
    $joins->{'c_val1'} = {
        from => 'bug_id',
        to => 'bug_id'.
        table => <<END;
            (SELECT bugs.bug_id, c.value1 AS c_value1
            FROM bugs
            INNER JOIN A ON A.a_id = bugs.a_id
            INNER JOIN B ON B.a_id = A.a_id
            INNER JOIN C ON C.b_id = B.b_id
            WHERE ...)
END
        as => 'subquery_hack1',
        join  => 'LEFT',
    };
    $joins->{'c_val2'} = {
        from => 'bug_id',
        to => 'bug_id'.
        table => <<END;
            (SELECT bugs.bug_id, c.value2 AS c_value2
            FROM bugs
            INNER JOIN A ON A.a_id = bugs.a_id
            INNER JOIN B ON B.a_id = A.a_id
            INNER JOIN C ON C.b_id = B.b_id
            WHERE ...)
END
        as => 'subquery_hack2',
        join  => 'LEFT',
    };
}

I tried to find a semi-obvious places to do this (or where to hack this into place), but I haven't been able to find a good candidate. Even a single subquery hack would be preferable to the above (which seems to require one per distinct buglist column).

As always, any guidance or nudge in the right direction would be greatly appreciated.


    --Matt


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bugzilla.org/pipermail/developers/attachments/20130106/6d43eedd/attachment.html>


More information about the developers mailing list