- undef $ct unless $thing{contest};
- debug $env => "Contest is $ct";
- local $Gruntmaster::Data::contest = $ct if $ct;
- my @thing = hgetall $thing{hash};
+ #debug $env => "Contest is $ct";
+ $thing{makers} //= sub { db(shift)->resultset($thing{rsname}) };
+ my $rs = $thing{makers}->($env);
+ $rs = $rs->search(undef, {order_by => 'me.id'}) unless $rs->is_ordered;
+ if (my $page = $env->{'gruntmaster.page'}) {
+ my $pages = $rs->count / PAGE_SIZE;
+ $page = $pages if $page == -1;
+ $rs = $rs->search(undef, {offset => ($page - 1) * PAGE_SIZE, ($page == $pages ? () : (rows => PAGE_SIZE))});
+ }
+ $rs = $rs->search(undef, {prefetch => $thing{prefetch}}) if exists $thing{prefetch};
+ my @thing = map +{rs => $_, $_->get_columns}, $rs->all;