Bug 17710 - C4::Matcher::get_matches and C4::ImportBatch::GetBestRecordMatch should use same logic
C4::ImportBatch::GetBestRecordMatch uses SQL to sort by score descending then candidate_match_id descending. With C4::Matcher::get_matches, I implement the same sort but use Perl code to do it, since we're sorting search results. It's a simple change, but it's in a big block of code, so I don't have unit tests. Signed-off-by: Alex Buckley <alexbuckley@catalyst.net.nz> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
parent
f97addef42
commit
6906b848a7
1 changed files with 4 additions and 1 deletions
|
@ -724,7 +724,10 @@ sub get_matches {
|
||||||
push @results, { 'record_id' => $authid, 'score' => $matches{$authid} };
|
push @results, { 'record_id' => $authid, 'score' => $matches{$authid} };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@results = sort { $b->{'score'} cmp $a->{'score'} } @results;
|
@results = sort {
|
||||||
|
$b->{'score'} cmp $a->{'score'} or
|
||||||
|
$b->{'record_id'} cmp $a->{'record_id'}
|
||||||
|
} @results;
|
||||||
if (scalar(@results) > $max_matches) {
|
if (scalar(@results) > $max_matches) {
|
||||||
@results = @results[0..$max_matches-1];
|
@results = @results[0..$max_matches-1];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue