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

(-)a/C4/Biblio.pm (-2 / +4 lines)
Lines 3100-3118 sub UpdateTotalIssues { Link Here
3100
        $exception->rethrow unless ( $exception->isa('Koha::Exceptions::Metadata::Invalid') );
3100
        $exception->rethrow unless ( $exception->isa('Koha::Exceptions::Metadata::Invalid') );
3101
        warn $exception;
3101
        warn $exception;
3102
        warn "UpdateTotalIssues could not get bibliographic record for biblionumber $biblionumber";
3102
        warn "UpdateTotalIssues could not get bibliographic record for biblionumber $biblionumber";
3103
        return;
3103
        return -1;
3104
    }
3104
    }
3105
    my $biblioitem = $biblio->biblioitem;
3105
    my $biblioitem = $biblio->biblioitem;
3106
    my ($totalissuestag, $totalissuessubfield) = GetMarcFromKohaField( 'biblioitems.totalissues' );
3106
    my ($totalissuestag, $totalissuessubfield) = GetMarcFromKohaField( 'biblioitems.totalissues' );
3107
    unless ($totalissuestag) {
3107
    unless ($totalissuestag) {
3108
        return 1; # There is nothing to do
3108
        return 0; # There is nothing to do
3109
    }
3109
    }
3110
3110
3111
    my $current_issues = $biblioitem->totalissues // 0;
3111
    if (defined $value) {
3112
    if (defined $value) {
3112
        $totalissues = $value;
3113
        $totalissues = $value;
3113
    } else {
3114
    } else {
3114
        $totalissues = $biblioitem->totalissues + $increase;
3115
        $totalissues = $biblioitem->totalissues + $increase;
3115
    }
3116
    }
3117
    return 0 if $current_issues == $totalissues;    # No need to update if no changes
3116
3118
3117
     my $field = $record->field($totalissuestag);
3119
     my $field = $record->field($totalissuestag);
3118
     if (defined $field) {
3120
     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