Igor Gariev (gariev) wrote in changelog,
Igor Gariev
gariev
changelog

[ljcom] r11068: LJSUP-10009: [internal]: show detailed s...

Committer: gariev
LJSUP-10009: [internal]: show detailed server info (svn revision, date of last commit)
U   trunk/cgi-bin/LJ/Hooks/Support.pm
Modified: trunk/cgi-bin/LJ/Hooks/Support.pm
===================================================================
--- trunk/cgi-bin/LJ/Hooks/Support.pm	2011-10-03 09:46:36 UTC (rev 11067)
+++ trunk/cgi-bin/LJ/Hooks/Support.pm	2011-10-04 07:51:35 UTC (rev 11068)
@@ -119,9 +119,34 @@
     LJ::Support::set_prop($spid, "language", "ru");
 });
 
+my $extra_info_cache = {valid_till => 0, extra_info => ''};
+
 LJ::register_hook('current_version_html', sub {
     my $text = LJ::Lang::ml('current.version');
-    return qq[<dl class="current-version"><dt>$text:</dt><dd>v.$LJ::CURRENT_VERSION</dd></dl>];
+ 
+    ## be more specific about /trunk - which revisions and date of last commit are there?
+    if ($LJ::CURRENT_VERSION eq 'trunk') {
+        my $time = time();
+        if ($extra_info_cache->{'valid_till'} < $time) { 
+            require "LJ/Maint/SVN.pm";
+            my @revisions;
+            my $date_of_latest_commit;
+            foreach my $repo (qw/livejournal ljcom ljcomint/) {
+                my $info = LJ::Maint::SVN->find_local_info($repo);
+                push @revisions, $info->{'revision'};
+                if (!$date_of_latest_commit || $date_of_latest_commit lt $info->{'date'}) {
+                    $date_of_latest_commit = $info->{'date'};
+                }
+            }
+            ## 2011-10-04T03:41:31.736347Z
+            $date_of_latest_commit =~ /^(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2})\.\d+Z/ or die;
+            my $last_update = LJ::TimeUtil->ago_text($time - LJ::TimeUtil->mysqldate_to_time("$1 $2", 1));
+            ## cache for 15 seconds on dev servers and forever on omega 
+            $extra_info_cache->{'valid_till'} = ($LJ::IS_LJCOM_BETA) ? $time+1e6 : $time+15;
+            $extra_info_cache->{'extra_info'} = " ($last_update, " . join("/", @revisions) . ")";
+        }
+    }
+    return qq[<dl class="current-version"><dt>$text:</dt><dd>v.$LJ::CURRENT_VERSION$extra_info_cache->{'extra_info'}</dd></dl>];
 });
 
 1;

Tags: gariev, ljcom, pm
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments