in reply to Re: Get top N rows in each group with DBIx::Class
in thread Get top N rows in each group with DBIx::Class
Hi Shadowsong, thanks very much for your reply and demo. I had seen that part of the doc and it looks promising, but the problem I am facing is that this filter ('N per "group"') must be applied after some other search calls on the RS.
Continuing the metaphor, this would be something like:
So the consuming code can do:sub by_genre { $_[0]->search({ 'me.genre' => $_[1] }); sub since { $_[0]->search({ 'me.released' => { '>=', $_[1] } });
I need to add a method that can act upon the existing ResultSet,my $rs = $schema->resultset('CD'); if ( my $genre = param->{'genre'} ) { $rs = $rs->by_genre( $genre ); } if ( my $since = param->{'since'} ) { $rs = $rs->since( $since ); }
It's not clear to me that the doc you linked to and demoed can be adapted to search an existing RS, but I'll keep experimenting. Thanks again.if ( my $limit = param->{'limit'} ) { $rs = $rs->limit_per_artist( $limit ); }
|
|---|