View | Details | Raw Unified | Return to bug 36474
Collapse All | Expand All

(-)a/C4/Biblio.pm (-2 / +4 lines)
Lines 3078-3096 sub UpdateTotalIssues { Link Here
3078
        $exception->rethrow unless ( $exception->isa('Koha::Exceptions::Metadata::Invalid') );
3078
        $exception->rethrow unless ( $exception->isa('Koha::Exceptions::Metadata::Invalid') );
3079
        warn $exception;
3079
        warn $exception;
3080
        warn "UpdateTotalIssues could not get bibliographic record for biblionumber $biblionumber";
3080
        warn "UpdateTotalIssues could not get bibliographic record for biblionumber $biblionumber";
3081
        return;
3081
        return -1;
3082
    }
3082
    }
3083
    my $biblioitem = $biblio->biblioitem;
3083
    my $biblioitem = $biblio->biblioitem;
3084
    my ($totalissuestag, $totalissuessubfield) = GetMarcFromKohaField( 'biblioitems.totalissues' );
3084
    my ($totalissuestag, $totalissuessubfield) = GetMarcFromKohaField( 'biblioitems.totalissues' );
3085
    unless ($totalissuestag) {
3085
    unless ($totalissuestag) {
3086
        return 1; # There is nothing to do
3086
        return 0; # There is nothing to do
3087
    }
3087
    }
3088
3088
3089
    my $current_issues = $biblioitem->totalissues // 0;
3089
    if (defined $value) {
3090
    if (defined $value) {
3090
        $totalissues = $value;
3091
        $totalissues = $value;
3091
    } else {
3092
    } else {
3092
        $totalissues = $biblioitem->totalissues + $increase;
3093
        $totalissues = $biblioitem->totalissues + $increase;
3093
    }
3094
    }
3095
    return 0 if $current_issues == $totalissues;    # No need to update if no changes
3094
3096
3095
     my $field = $record->field($totalissuestag);
3097
     my $field = $record->field($totalissuestag);
3096
     if (defined $field) {
3098
     if (defined $field) {
(-)a/misc/cronjobs/update_totalissues.pl (-6 / +8 lines)
Lines 98-104 my $dbh = C4::Context->dbh; Link Here
98
$dbh->{AutoCommit} = 0;
98
$dbh->{AutoCommit} = 0;
99
99
100
my $num_bibs_processed = 0;
100
my $num_bibs_processed = 0;
101
my $num_bibs_error = 0;
101
my $num_bibs_updated   = 0;
102
my $num_bibs_error     = 0;
102
103
103
my $starttime = time();
104
my $starttime = time();
104
105
Lines 169-181 sub process_query { Link Here
169
            my $ret;
170
            my $ret;
170
            if ( $incremental && $totalissues > 0 ) {
171
            if ( $incremental && $totalissues > 0 ) {
171
                $ret = UpdateTotalIssues( $biblionumber, $totalissues, undef, 1 );
172
                $ret = UpdateTotalIssues( $biblionumber, $totalissues, undef, 1 );
172
            }
173
            } else {
173
            else {
174
                $ret = UpdateTotalIssues( $biblionumber, 0, $totalissues, 1 );
174
                $ret = UpdateTotalIssues( $biblionumber, 0, $totalissues, 1 );
175
            }
175
            }
176
            unless ($ret) {
176
            if ( $ret == -1 ) {
177
                print "Error while processing bib $biblionumber\n" if $verbose;
177
                print "Error while processing bib $biblionumber\n" if $verbose;
178
                $num_bibs_error++;
178
                $num_bibs_error++;
179
            } elsif ( $ret == 1 ) {
180
                $num_bibs_updated++;
179
            }
181
            }
180
        }
182
        }
181
        if ( not $test_only and ( $num_bibs_processed % $commit ) == 0 ) {
183
        if ( not $test_only and ( $num_bibs_processed % $commit ) == 0 ) {
Lines 199-205 Update total issues count script report Link Here
199
Run started at:                         $starttime
201
Run started at:                         $starttime
200
Run ended at:                           $endtime
202
Run ended at:                           $endtime
201
Total run time:                         $totaltime ms
203
Total run time:                         $totaltime ms
202
Number of bibs modified:                $num_bibs_processed
204
Number of bibs processed:               $num_bibs_processed
205
Number of bibs modified:                $num_bibs_updated
203
Number of bibs with error:              $num_bibs_error
206
Number of bibs with error:              $num_bibs_error
204
_SUMMARY_
207
_SUMMARY_
205
    $summary .= "\n****  Ran in test mode only  ****\n" if $test_only;
208
    $summary .= "\n****  Ran in test mode only  ****\n" if $test_only;
206
- 

Return to bug 36474