Bugzilla – Attachment 86516 Details for
Bug 21560
Optimize ODS exports
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21560: Optimize ODS export of gather_print_notices.pl
Bug-21560-Optimize-ODS-export-of-gatherprintnotice.patch (text/plain), 3.60 KB, created by
Martin Renvoize (ashimema)
on 2019-03-12 12:18:19 UTC
(
hide
)
Description:
Bug 21560: Optimize ODS export of gather_print_notices.pl
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2019-03-12 12:18:19 UTC
Size:
3.60 KB
patch
obsolete
>From 34d2d388983b04aaaaae92d9d3684407bcc59215 Mon Sep 17 00:00:00 2001 >From: Fridolin Somers <fridolin.somers@biblibre.com> >Date: Fri, 7 Dec 2018 10:30:30 +0100 >Subject: [PATCH] Bug 21560: Optimize ODS export of gather_print_notices.pl > >Like previous patch, the call on OpenOffice-OODoc lib can be optimized. >Based on https://grep.metacpan.org/search?qci=&q=expandTable&qft=&qd=OpenOffice-OODoc&f=examples%2Ftext2table > >Test plan inspired from Bug 11679. > >Test plan: >- define your ODUE notice for the print template as: >cardnumber:patron:email:item ><<borrowers.cardnumber>>:<<borrowers.firstname>> <<borrowers.surname>>:<<borrowers.email>>:<item><<items.barcode>></item> >- define overdues rules for a patron category >- check-out 2 items using a due date in order to generate the overdue notices >- check-in these 2 items >- launch the script /misc/cronjobs/overdue_notices.pl >- the 'message_queue' table should now contain 2 new entries >- launch the gather_print_notices cronjob : > perl misc/cronjobs/gather_print_notices.pl /tmp/test --ods --letter_code=OVERDUE -d=: >- A ods file should be generated in your /tmp/test directory >- Compare times with and without patch > >Signed-off-by: David Nind <david@davidnind.com> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > misc/cronjobs/gather_print_notices.pl | 24 +++++++++++++----------- > 1 file changed, 13 insertions(+), 11 deletions(-) > >diff --git a/misc/cronjobs/gather_print_notices.pl b/misc/cronjobs/gather_print_notices.pl >index cb1aecf94d..ebd3dd86f5 100755 >--- a/misc/cronjobs/gather_print_notices.pl >+++ b/misc/cronjobs/gather_print_notices.pl >@@ -254,18 +254,16 @@ sub generate_ods { > my $messages = $params->{messages}; > my $filepath = $params->{filepath}; > >+ # Create document > use OpenOffice::OODoc; > my $tmpdir = dirname $filepath; > odfWorkingDirectory( $tmpdir ); >- my $container = odfContainer( $filepath, create => 'spreadsheet' ); >- my $doc = odfDocument ( >- container => $container, >- part => 'content' >- ); >- my $table = $doc->getTable(0); >+ my $doc = odfDocument( file => $filepath, create => 'spreadsheet' ); > >+ # Prepare sheet > my @headers; >- my ( $nb_rows, $nb_cols, $i ) = ( scalar(@$messages), 0, 0 ); >+ my @rows; >+ my $i = 0; > foreach my $message ( @$messages ) { > my @lines = split /\n/, $message->{content}; > chomp for @lines; >@@ -273,10 +271,13 @@ sub generate_ods { > # We don't have headers, get them > unless ( @headers ) { > @headers = split $delimiter, $lines[0]; >+ my $nb_cols = scalar @headers; >+ my $nb_rows = scalar @$messages; >+ my $sheet = $doc->expandTable( 0, $nb_rows + 1, $nb_cols ); >+ @rows = $doc->getTableRows($sheet); > >- $nb_cols = @headers; >- $doc->expandTable( $table, $nb_rows + 1, $nb_cols ); >- my $row = $doc->getRow( $table, 0 ); >+ # Write headers row >+ my $row = $rows[0]; > my $j = 0; > for my $header ( @headers ) { > $doc->cellValue( $row, $j, Encode::encode( 'UTF8', $header ) ); >@@ -285,10 +286,11 @@ sub generate_ods { > $i = 1; > } > >+ # Write all rows > shift @lines; # remove headers > for my $line ( @lines ) { > my @row_data = split $delimiter, $line; >- my $row = $doc->getRow( $table, $i ); >+ my $row = $rows[$i]; > # Note scalar(@$row_data) should be equal to $nb_cols > for ( my $j = 0 ; $j < scalar(@row_data) ; $j++ ) { > my $value = Encode::encode( 'UTF8', $row_data[$j] ); >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 21560
:
80470
|
80565
|
80683
|
82951
|
84258
|
84259
|
84693
|
84694
|
85264
|
85265
|
86084
|
86515
| 86516 |
86517
|
86518
|
86519