From: Don Armstrong Date: Thu, 14 Jun 2007 12:49:23 +0000 (+0100) Subject: - Indicate date of last activity (closes: #207065) X-Git-Tag: release/2.6.0~556^2~3 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=d3924023f4e1a2f421799300cae1a069909579d4;p=debbugs.git - Indicate date of last activity (closes: #207065) --- diff --git a/Debbugs/Common.pm b/Debbugs/Common.pm index 9776392e..60e2c309 100644 --- a/Debbugs/Common.pm +++ b/Debbugs/Common.pm @@ -43,11 +43,12 @@ BEGIN{ qw(getmaintainers_reverse) ], misc => [qw(make_list)], + date => [qw(secs_to_english)], quit => [qw(quit)], lock => [qw(filelock unfilelock @cleanups)], ); @EXPORT_OK = (); - Exporter::export_ok_tags(qw(lock quit util misc)); + Exporter::export_ok_tags(qw(lock quit date util misc)); $EXPORT_TAGS{all} = [@EXPORT_OK]; } @@ -239,6 +240,32 @@ sub getmaintainers_reverse{ return $_maintainer_rev; } +=head1 DATE + + my $english = secs_to_english($seconds); + my ($days,$english) = secs_to_english($seconds); + +XXX This should probably be changed to use Date::Calc + +=cut + +sub secs_to_english{ + my ($seconds) = @_; + + my $days = int($seconds / 86400); + my $years = int($days / 365); + $days -= $years * 365; + my $result; + my @age; + push @age, "1 year" if ($years == 1); + push @age, "$years years" if ($years > 1); + push @age, "1 day" if ($days == 1); + push @age, "$days days" if ($days > 1); + $result .= join(" and ", @age); + + return wantarray?($days,$result):$result; +} + =head1 LOCK diff --git a/Debbugs/Status.pm b/Debbugs/Status.pm index 5fb5413d..bda64abd 100644 --- a/Debbugs/Status.pm +++ b/Debbugs/Status.pm @@ -159,6 +159,7 @@ sub read_bug{ die "One of bug or summary must be passed to read_bug" if not exists $param{bug} and not exists $param{summary}; my $status; + my $log; if (not defined $param{summary}) { my ($lref, $location) = @param{qw(bug location)}; if (not defined $location) { @@ -166,6 +167,7 @@ sub read_bug{ return undef if not defined $location; } $status = getbugcomponent($lref, 'summary', $location); + $log = getbugcomponent($lref, 'log' , $location); return undef unless defined $status; } else { @@ -216,6 +218,8 @@ sub read_bug{ $data{$field} = decode_rfc1522($data{$field}); } } + # Add log last modified time + $data{log_modified} = (stat($log))[9]; return \%data; } diff --git a/cgi/pkgreport.cgi b/cgi/pkgreport.cgi index 7f16855b..ad4d2883 100755 --- a/cgi/pkgreport.cgi +++ b/cgi/pkgreport.cgi @@ -10,7 +10,7 @@ require './common.pl'; use Debbugs::Config qw(:globals :text); use Debbugs::User; use Debbugs::CGI qw(version_url); -use Debbugs::Common qw(getparsedaddrs); +use Debbugs::Common qw(getparsedaddrs :date); use Debbugs::Bugs qw(get_bugs); use vars qw($gPackagePages $gWebDomain %gSeverityDisplay @gSeverityList); @@ -647,27 +647,30 @@ sub pkg_htmlindexentrystatus { split /[,\s]+/,$status{forwarded} ); } - my $daysold = int((time - $status{date}) / 86400); # seconds to days - if ($daysold >= 7) { + # Check the age of the logfile + my ($days_last,$eng_last) = secs_to_english(time - $status{log_modified}); + my ($days,$eng) = secs_to_english(time - $status{date}); + + if ($days >= 7) { my $font = ""; my $efont = ""; - $font = "em" if ($daysold > 30); - $font = "strong" if ($daysold > 60); + $font = "em" if ($days > 30); + $font = "strong" if ($days > 60); $efont = "" if ($font); $font = "<$font>" if ($font); - my $yearsold = int($daysold / 365); - $daysold -= $yearsold * 365; - - $result .= ";\n $font"; - my @age; - push @age, "1 year" if ($yearsold == 1); - push @age, "$yearsold years" if ($yearsold > 1); - push @age, "1 day" if ($daysold == 1); - push @age, "$daysold days" if ($daysold > 1); - $result .= join(" and ", @age); - $result .= " old$efont"; + $result .= ";\n ${font}$eng old$efont"; } + if ($days_last > 7) { + my $font = ""; + my $efont = ""; + $font = "em" if ($days_last > 30); + $font = "strong" if ($days_last > 60); + $efont = "" if ($font); + $font = "<$font>" if ($font); + + $result .= ";\n ${font}Modified $eng_last ago$efont"; + } } $result .= "."; diff --git a/debian/changelog b/debian/changelog index 6ccafaa3..101666f5 100644 --- a/debian/changelog +++ b/debian/changelog @@ -184,6 +184,7 @@ debbugs (2.4.2) UNRELEASED; urgency=low - Split out packages so that you don't have to install the mail stuff unless you want it. - Only mail duplicated recipients once (closes: #172635) + - Indicate date of last activity (closes: #207065) -- Colin Watson Fri, 20 Jun 2003 18:57:25 +0100