r1362@llin: dpavlin | 2007-10-30 02:46:05 +0100
authorDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 30 Oct 2007 01:46:41 +0000 (01:46 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 30 Oct 2007 01:46:41 +0000 (01:46 +0000)
 Show indicators (available when using WebPAC::Input::MARC) as
 first two subfileds in statistics insted in alphabetical order

git-svn-id: svn+ssh://mjesec/home/dpavlin/svn/webpac2/trunk@909 07558da8-63fa-0310-ba24-9fe276d99e06

TODO
lib/WebPAC/Input.pm
t/2-input.t

diff --git a/TODO b/TODO
index a66da93..93f4228 100644 (file)
--- a/TODO
+++ b/TODO
@@ -42,8 +42,8 @@
 + simpliest possible conf/llin.yml as example
 + WebPAC::Output::JSON to produce data for Simile's exhibit
 + leader from WebPAC::Input::MARC is now available as rec('leader')
++ show i1 and i2 in statistcs specially (sorted first)
 - indicator(field,nr) nr=1|2 for MARC input
-- show i1 and i2 in statistcs specially
 - load_ds/save_ds should use on-disk hash to preserve inodes
 - validate should ignore modify_file
 - add option to specify output marc path in config.yml
index d8a2f0b..430d197 100644 (file)
@@ -531,12 +531,19 @@ sub stats {
                        my $o = sprintf("%4s %d ~", $f, $v);
 
                        if (defined($s->{sf}->{$f})) {
+                               my @subfields = keys %{ $s->{sf}->{$f} };
+warn "$f has subfields ",dump( @subfields );
                                map {
                                        $o .= sprintf(" %s:%d%s", $_, 
                                                $s->{sf}->{$f}->{$_}->{count},
                                                $s->{sf}->{$f}->{$_}->{repeatable} ? '*' : '',
                                        );
-                               } sort keys %{ $s->{sf}->{$f} };
+                               } (
+                                       # first indicators
+                                       sort( grep(  /^i[12]$/, @subfields ) ),
+                                       # then subfileds
+                                       sort( grep( !/^i[12]$/, @subfields ) ),
+                               );
                        }
 
                        if (my $v_r = $s->{repeatable}->{$f}) {
index a2cd982..9a2a78d 100755 (executable)
@@ -107,13 +107,13 @@ test_start_limit($input, $size, 3, 0);
 test_start_limit($input, 3, $size, $size - 2);
 test_start_limit($input, 1, $size + 2, $size);
 
-ok(my $s = $input->stats, 'stats');
+ok(my $s = $input->stats, "$module stats");
 diag "stats:\n$s" if ($debug);
 
 $module = 'WebPAC::Input::MARC';
 diag "testing with $module";
 
-ok($input = new WebPAC::Input( module => $module, no_log => $no_log, no_progress_bar => 1 ), "new $module");
+ok($input = new WebPAC::Input( module => $module, no_log => $no_log, no_progress_bar => 1, stats => 1 ), "new $module");
 
 ok($input->open( path => "$abs_path/data/marc.iso" ), "open marc.iso");
 
@@ -121,6 +121,9 @@ test_after_open($input);
 
 test_fetch($input, $input->size);
 
+ok(my $s = $input->stats, "$module stats");
+
+diag "stats:\n$s" if ($debug);
 # test modify_record
 $module = 'WebPAC::Input::Test';
 ok($input = new WebPAC::Input( module => $module, no_log => $no_log, no_progress_bar => 1, debug => $debug ), "new $module");