$rank = "FIRST((SELECT create_date FROM biblio.record_entry rbr WHERE rbr.id = m.source))";
} elsif ($sort_filter eq 'edit_date') {
$rank = "FIRST((SELECT edit_date FROM biblio.record_entry rbr WHERE rbr.id = m.source))";
+ } elsif ($sort_filter eq 'container_date' && @{$$flat_plan{container_list}}) {
+ # Just the first container for now
+ my $container_id = $self->QueryParser->quote_value(@{$$flat_plan{container_list}}[0]);
+ $rank = "FIRST((SELECT MAX(create_time) FROM container.biblio_record_entry_bucket_item cbrebi WHERE cbrebi.target_biblio_record_entry = m.source AND cbrebi.bucket = " . $container_id . "))";
} else {
# default to rel ranking
$rank = $rel;
my $uses_bre = 0;
my $uses_mrd = 0;
my $uses_mrv = 0;
+ my @container_list;
my @rank_list;
for my $node ( @{$self->query_nodes} ) {
my $rec_field = 'ci.target_biblio_record_entry';
if ($class eq 'bre') {
$class = 'biblio_record_entry';
+ push @container_list, $cid;
} elsif ($class eq 'acn') {
$class = 'call_number';
$rec_field = 'cn.record';
with => $with,
uses_bre => $uses_bre,
uses_mrv => $uses_mrv,
- uses_mrd => $uses_mrd
+ uses_mrd => $uses_mrd,
+ container_list => \@container_list
};
}