finally fixed count with unique_biblionumber
authorDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 3 Jan 2017 08:11:24 +0000 (09:11 +0100)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 3 Jan 2017 08:11:24 +0000 (09:11 +0100)
html.pl

diff --git a/html.pl b/html.pl
index 10ad3d5..cc7089c 100755 (executable)
--- a/html.pl
+++ b/html.pl
@@ -318,7 +318,7 @@ while( my $row = $sth_select_authors->fetchrow_hashref ) {
                                        $type_stats->{_count_each_type}->{$type}++;
 
                                        if ( $type =~ m/(edt|trl|com|ctb)/ ) {
-                                               push @{ $authors->{$authid}->{_sec}->{ $category } }, $row->{biblionumber};
+                                               push @{ $authors->{$authid}->{__sec}->{ $category } }, $row->{biblionumber};
                                                push @{ $authors->{$authid}->{$type}->{ $category } }, $row->{biblionumber};
                                                $type =~ s/(com|ctb)/_ostalo/;
                                                push @{ $authors->{$authid}->{$type}->{ $category } }, $row->{biblionumber};
@@ -433,14 +433,21 @@ sub author_html {
        }
 }
 
+my @toc_type_label = (
+'aut' => 'Primarno autorstvo',
+'edt' => 'Uredništva',
+'trl' => 'Prijevodi',
+'_ostalo' => 'Ostalo',
+);
+
 
 sub count_author_years {
        my $years = shift;
        my ($authid) = @_;
        foreach my $type ( keys %{ $authors->{$authid} } ) {
+               next if $type =~ m/^_/;
                foreach my $category ( keys %{ $authors->{$authid}->{$type} } ) {
-                       next if $category =~ m/^_/;
-                       foreach my $biblionumber ( @{ $authors->{$authid}->{$type}->{$category} } ) {
+                       foreach my $biblionumber ( unique_biblionumber @{ $authors->{$authid}->{$type}->{$category} } ) {
                                $years->{ $biblio_year->{ $biblionumber } }->{ $type . '-' . $category }++;
                        }
                }
@@ -448,17 +455,12 @@ sub count_author_years {
        return $years;
 }
 
-my @toc_type_label = (
-'aut' => 'Primarno autorstvo',
-'edt' => 'Uredništva',
-'trl' => 'Prijevodi',
-'_ostalo' => 'Ostalo',
-);
-
 sub html_year_selection {
        my $fh = shift;
        my @authids = @_;
 
+       debug 'html_year_selection authids=', [ @authids ];
+
        print $fh qq|<span id="years">Godine:\n|;
        my $type_cat_count = {};
        my $years;
@@ -467,6 +469,8 @@ sub html_year_selection {
                $years = count_author_years( $years, $authid );
        }
 
+       debug 'years' => $years;
+
        foreach my $year ( sort { $b <=> $a } keys %$years ) {
                print $fh qq|<label><input name="year_selection" value="$year" type=checkbox onClick="toggle_year($year, this)" checked="checked">$year</label>&nbsp;\n|;
                foreach my $type_cat ( keys %{ $years->{$year} } ) {
@@ -495,6 +499,8 @@ var type_cat_count = |, encode_json($type_cat_count), q|;
 
        |;
 
+       debug 'type_cat_count' => $type_cat_count;
+
        # TOC
        print $fh qq|<ul id="toc">\n|;
        my $i = 0;
@@ -558,7 +564,7 @@ my $department_category_author;
 foreach my $department ( sort keys %$auth_department ) {
        foreach my $authid ( sort @{ $auth_department->{$department} } ) {
                my   @categories = keys %{ $authors->{$authid}->{aut} };
-               push @categories,  keys %{ $authors->{$authid}->{_sec} };
+               push @categories,  keys %{ $authors->{$authid}->{__sec} };
                foreach my $category ( sort @categories ) {
                        push @{ $department_category_author->{$department}->{$category} }, $authid;
                        push @{ $department_category_author->{'AAA_ukupno'}->{$category} }, $authid if $department_in_sum->{$department};