Bugzilla – Attachment 117201 Details for
Bug 27048
Add timestamps to verbose output of rebuild_zebra.pl
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27048: (follow-up) Use DateTime instead of POSIX
Bug-27048-follow-up-Use-DateTime-instead-of-POSIX.patch (text/plain), 2.27 KB, created by
Martin Renvoize (ashimema)
on 2021-02-23 12:18:15 UTC
(
hide
)
Description:
Bug 27048: (follow-up) Use DateTime instead of POSIX
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2021-02-23 12:18:15 UTC
Size:
2.27 KB
patch
obsolete
>From f01e7bc536a3d22daca325961bbdcf246037aaca Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Tue, 23 Feb 2021 12:17:00 +0000 >Subject: [PATCH] Bug 27048: (follow-up) Use DateTime instead of POSIX > >This introduces additional dependancies and builds DateTime objects >multiple times.. I'm not sure it's worth it. >--- > misc/migration_tools/rebuild_zebra.pl | 30 +++++++++++---------------- > 1 file changed, 12 insertions(+), 18 deletions(-) > >diff --git a/misc/migration_tools/rebuild_zebra.pl b/misc/migration_tools/rebuild_zebra.pl >index 8fd611a83b..98988d7b4f 100755 >--- a/misc/migration_tools/rebuild_zebra.pl >+++ b/misc/migration_tools/rebuild_zebra.pl >@@ -18,6 +18,8 @@ > use Modern::Perl; > > use Koha::Script; >+use Koha::DateUtils; >+use DateTime::Format::Duration; > use C4::Context; > use Getopt::Long; > use Fcntl qw(:flock); >@@ -209,9 +211,9 @@ if( !defined $LockFH ) { > # the lockfile) > }; > >-my $start_time = time(); >+my $start_time = dt_from_string; > if ( $verbose_logging ) { >- my $pretty_time = POSIX::strftime("%H:%M:%S",localtime($start_time)); >+ my $pretty_time = dt_from_string()->strftime("%H:%M:%S"); > print "Zebra configuration information\n"; > print "================================\n"; > print "Zebra biblio directory = $biblioserverdir\n"; >@@ -833,22 +835,14 @@ sub _create_lockfile { #returns undef on failure > > sub pretty_time { > use integer; >- my $now = time; >- my $elapsed = $now - $start_time; >- local $_ = $elapsed; >- my ( $d, $h, $m, $s ); >- $s = $_ % 60; >- $_ /= 60; >- $m = $_ % 60; >- $_ /= 60; >- $h = $_ % 24; >- $_ /= 24; >- $d = $_; >- >- my $now_pretty = POSIX::strftime("%H:%M:%S",localtime($now)); >- my $elapsed_pretty = $d ? "[$d:$h:$m:$s]" : $h ? "[$h:$m:$s]" : $m ? "[$m:$s]" : "[$s]"; >- >- return "$now_pretty $elapsed_pretty"; >+ my $now = dt_from_string; >+ my $elapsed = $now->delta_ms($start_time); >+ my $duration_formatter = DateTime::Format::Duration->new(pattern => '%e:%H:%M:%S'); >+ >+ my $now_pretty = $now->strftime("%H:%M:%S"); >+ #my $elapsed_pretty = $d ? "[$d:$h:$m:$s]" : $h ? "[$h:$m:$s]" : $m ? "[$m:$s]" : "[$s]"; >+ >+ return "$now_pretty [" . $duration_formatter->format_duration($elapsed) . "]"; > } > > sub print_usage { >-- >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 27048
:
113773
|
113780
|
115931
|
117201
|
117418
|
117452
|
117617