/usr/share/perl5/Prophet/Resolver/FromResolutionDB.pm is in libprophet-perl 0.750-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | package Prophet::Resolver::FromResolutionDB;
use Any::Moose;
use Prophet::Change;
use Prophet::Collection;
use JSON;
use Digest::SHA 'sha1_hex';
extends 'Prophet::Resolver';
sub run {
my $self = shift;
my $conflicting_change = shift;
my $conflict = shift;
my $resdb = shift; # XXX: we want diffrent collection actually now
require Prophet::Collection;
my $res = Prophet::Collection->new(
handle => $resdb,
# XXX TODO PULL THIS TYPE FROM A CONSTANT
type => '_prophet_resolution-' . $conflicting_change->fingerprint
);
$res->matching( sub {1} );
return unless $res->count;
my %answer_map;
my %answer_count;
for my $answer ($res->items) {
my $key = sha1_hex( to_json($answer->get_props, {utf8 => 1, pretty => 1, canonical => 1}));
$answer_map{$key} ||= $answer;
$answer_count{$key}++;
}
my $best = ( sort { $answer_count{$b} <=> $answer_count{$a} } keys %answer_map )[0];
my $answer = $answer_map{$best};
my $resolution = Prophet::Change->new_from_conflict($conflicting_change);
for my $prop_conflict ( @{ $conflicting_change->prop_conflicts } ) {
$resolution->add_prop_change(
name => $prop_conflict->name,
old => $prop_conflict->source_old_value,
new => $answer->prop( $prop_conflict->name ),
);
}
return $resolution;
}
__PACKAGE__->meta->make_immutable;
no Any::Moose;
1;
|