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

(-)a/C4/Biblio.pm (-4 / +6 lines)
Lines 3063-3081 sub UpdateTotalIssues { Link Here
3063
        my $exception = $@;
3063
        my $exception = $@;
3064
        $exception->rethrow unless ( $exception->isa('Koha::Exceptions::Metadata::Invalid') );
3064
        $exception->rethrow unless ( $exception->isa('Koha::Exceptions::Metadata::Invalid') );
3065
        warn "UpdateTotalIssues could not get biblio record";
3065
        warn "UpdateTotalIssues could not get biblio record";
3066
        return;
3066
        return -1;
3067
    }
3067
    }
3068
    my $biblioitem = $biblio->biblioitem;
3068
    my $biblioitem = $biblio->biblioitem;
3069
    my ($totalissuestag, $totalissuessubfield) = GetMarcFromKohaField( 'biblioitems.totalissues' );
3069
    my ($totalissuestag, $totalissuessubfield) = GetMarcFromKohaField( 'biblioitems.totalissues' );
3070
    unless ($totalissuestag) {
3070
    unless ($totalissuestag) {
3071
        return 1; # There is nothing to do
3071
        return 0; # There is nothing to do
3072
    }
3072
    }
3073
3073
3074
    if (defined $value) {
3074
    my $current_issues = $biblioitem->totalissues // 0;
3075
    if ( defined $value ) {
3075
        $totalissues = $value;
3076
        $totalissues = $value;
3076
    } else {
3077
    } else {
3077
        $totalissues = $biblioitem->totalissues + $increase;
3078
        $totalissues = $current_issues + $increase;
3078
    }
3079
    }
3080
    return 0 if $current_issues == $totalissues;    # No need to update if no changes
3079
3081
3080
     my $field = $record->field($totalissuestag);
3082
     my $field = $record->field($totalissuestag);
3081
     if (defined $field) {
3083
     if (defined $field) {
(-)a/misc/cronjobs/update_totalissues.pl (-4 / +7 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 173-181 sub process_query { Link Here
173
            else {
174
            else {
174
                $ret = UpdateTotalIssues( $biblionumber, 0, $totalissues );
175
                $ret = UpdateTotalIssues( $biblionumber, 0, $totalissues );
175
            }
176
            }
176
            unless ($ret) {
177
            if ( $ret == -1 ) {
177
                print "Error while processing bib $biblionumber\n" if $verbose;
178
                print "Error while processing bib $biblionumber\n" if $verbose;
178
                $num_bibs_error++;
179
                $num_bibs_error++;
180
            } elsif ( $ret == 1 ) {
181
                $num_bibs_updated++;
179
            }
182
            }
180
        }
183
        }
181
        if ( not $test_only and ( $num_bibs_processed % $commit ) == 0 ) {
184
        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
202
Run started at:                         $starttime
200
Run ended at:                           $endtime
203
Run ended at:                           $endtime
201
Total run time:                         $totaltime ms
204
Total run time:                         $totaltime ms
202
Number of bibs modified:                $num_bibs_processed
205
Number of bibs processed:               $num_bibs_processed
206
Number of bibs modified:                $num_bibs_updated
203
Number of bibs with error:              $num_bibs_error
207
Number of bibs with error:              $num_bibs_error
204
_SUMMARY_
208
_SUMMARY_
205
    $summary .= "\n****  Ran in test mode only  ****\n" if $test_only;
209
    $summary .= "\n****  Ran in test mode only  ****\n" if $test_only;
206
- 

Return to bug 36474