requires 'HTML::TableExtract';
requires 'File::Path';
requires 'Text::Unaccent::PurePerl';
+requires 'Statistics::Descriptive';
features(
'profile' => [
use File::Path qw(mkpath);
use Text::Unaccent::PurePerl;
use Digest::MD5;
+use Statistics::Descriptive;
use MojoFacets::Import::File;
use MojoFacets::Import::HTMLTable;
sub lookup {
warn "# lookup ",dump @_;
- my ( $vals, $on_path, $on_col, $code ) = @_;
+ my ( $vals, $on_path, $on_col, $code, $stat_code ) = @_;
die "code is not sub{ ... } but ", dump $code unless ref $code eq 'CODE';
if ( ! exists $loaded->{$on_path} ) {
#warn "XXX ",dump $lookup_path_col->{$on_path}->{$on_col};
}
+ my $stat;
+ $stat = Statistics::Descriptive::Full->new() if $stat_code;
+
foreach my $v ( @$vals ) {
foreach my $i ( @{ $lookup_path_col->{$on_path}->{$on_col}->{$v} } ) {
$on = $items->[$i];
#warn "XXX lookup code $v $i ",dump $on;
- $code->();
+ $code->($stat);
}
+ $stat_code->( $stat ) if $stat_code;
}
}
lookup($row->{issn}, 'nabava', => 'issn', sub {
push @{ $update->{listprice} }, $on->{listprice};
+ shift->add_data( $on->{listprice} );
+},sub {
+ my $stat = shift;
+ $update->{price_min} = $stat->min;
+# $update->{price_max} = $stat->max;
+ $update->{price_check} = $stat->min * 5 - $row->{cijena}->[0];
});