reduce using $out in code
authorDobrica Pavlinusic <dpavlin@rot13.org>
Sat, 19 Jun 2010 12:21:43 +0000 (14:21 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Sat, 19 Jun 2010 12:21:43 +0000 (14:21 +0200)
This allows us to generate various summaries over all rows on screen.

lib/MojoFacets/Data.pm
public/code/Cited Author,Year.count.pl [new file with mode: 0644]
templates/data/items/table.html.ep

index 08a0a64..23ba083 100644 (file)
@@ -631,6 +631,7 @@ sub items {
 
        my $sorted_items;
        my $from_end = $sort eq 'd' ? $#$filtered : 0;
+       my $out;
        foreach ( 0 .. $limit ) {
                my $i = $_ + $offset;
                last unless defined $filtered->[$i];
@@ -676,6 +677,7 @@ sub items {
                code_depends => $code_depends,
                code_description => $code_description,
                code_path => $code_path,
+               out => $out,
        );
 
 }
diff --git a/public/code/Cited Author,Year.count.pl b/public/code/Cited Author,Year.count.pl
new file mode 100644 (file)
index 0000000..fde903f
--- /dev/null
@@ -0,0 +1,3 @@
+foreach my $author ( @{ $row->{'Cited Author'} } ) {\r
+  $out->{ $author }->{ $_ }++ foreach @{ $row->{'Year'} };\r
+}
\ No newline at end of file
index 3f3f9b7..10ab4fc 100644 (file)
@@ -58,10 +58,16 @@ filter
 
 </table>
 <form id=eval method=post style="<%= $code ? '' : 'display:none' %>">
+
 % my $error = stash('eval_error');
 % if ( $error ) {
 <div class=error><%= $error %></div>
 % }
+
+% if ( $out ) {
+<pre class=debug><%= dumper $out %></pre>
+% }
+
 % my $rows = scalar split(/\n/,$code);
 <textarea name=code rows=<%= $rows %>><%= $code %></textarea>
 <input name=test   type=submit value="Test code">