FEATURE: Display 'last updated' on dashboard, improve release notes link (#7560)

approved
#1

FEATURE: Display ‘last updated’ on dashboard, improve release notes link (#7560)

diff --git a/app/assets/javascripts/admin/controllers/admin-dashboard-general.js.es6 b/app/assets/javascripts/admin/controllers/admin-dashboard-general.js.es6
index 044ad68..6997cb9 100644
--- a/app/assets/javascripts/admin/controllers/admin-dashboard-general.js.es6
+++ b/app/assets/javascripts/admin/controllers/admin-dashboard-general.js.es6
@@ -111,13 +111,6 @@ export default Ember.Controller.extend(PeriodComputationMixin, {
     return { startDate, endDate };
   },
 
-  @computed("model.attributes.updated_at")
-  updatedTimestamp(updatedAt) {
-    return moment(updatedAt)
-      .tz(moment.tz.guess())
-      .format("LLL");
-  },
-
   _reportsForPeriodURL(period) {
     return Discourse.getURL(`/admin?period=${period}`);
   }
diff --git a/app/assets/javascripts/admin/models/admin-dashboard.js.es6 b/app/assets/javascripts/admin/models/admin-dashboard.js.es6
index 15a1114..20cdbe2 100644
--- a/app/assets/javascripts/admin/models/admin-dashboard.js.es6
+++ b/app/assets/javascripts/admin/models/admin-dashboard.js.es6
@@ -1,6 +1,10 @@
 import { ajax } from "discourse/lib/ajax";
 
-const GENERAL_ATTRIBUTES = ["updated_at"];
+const GENERAL_ATTRIBUTES = [
+  "updated_at",
+  "discourse_updated_at",
+  "release_notes_link"
+];
 
 const AdminDashboard = Discourse.Model.extend({});
 
diff --git a/app/assets/javascripts/admin/templates/dashboard_general.hbs b/app/assets/javascripts/admin/templates/dashboard_general.hbs
index 2d8c0e4..2feaefe 100644
--- a/app/assets/javascripts/admin/templates/dashboard_general.hbs
+++ b/app/assets/javascripts/admin/templates/dashboard_general.hbs
@@ -115,8 +115,12 @@
         <div class="last-dashboard-update">
           <div>
             <h4>{{i18n "admin.dashboard.last_updated"}} </h4>
-            <p>{{updatedTimestamp}}</p>
-            <a rel="noopener" target="_blank" href="https://meta.discourse.org/tags/release-notes" class="btn btn-default">
+            <p>{{format-date model.attributes.updated_at leaveAgo="true"}}</p>
+          </div>
+          <div>
+            <h4>{{i18n "admin.dashboard.discourse_last_updated"}} </h4>
+            <p>{{format-date model.attributes.discourse_updated_at leaveAgo="true"}}</p>
+            <a rel="noopener" target="_blank" href={{model.attributes.release_notes_link}} class="btn btn-default">
               {{i18n "admin.dashboard.whats_new_in_discourse"}}
             </a>
           </div>
diff --git a/app/assets/stylesheets/common/admin/dashboard.scss b/app/assets/stylesheets/common/admin/dashboard.scss
index bb4a918..8d42b71 100644
--- a/app/assets/stylesheets/common/admin/dashboard.scss
+++ b/app/assets/stylesheets/common/admin/dashboard.scss
@@ -249,6 +249,7 @@
     .last-dashboard-update {
       text-align: center;
       display: flex;
+      flex-direction: column;
       justify-content: center;
       div {
         align-self: center;
diff --git a/app/models/admin_dashboard_general_data.rb b/app/models/admin_dashboard_general_data.rb
index 915ddd1..84bff94 100644
--- a/app/models/admin_dashboard_general_data.rb
+++ b/app/models/admin_dashboard_general_data.rb
@@ -2,8 +2,11 @@
 
 class AdminDashboardGeneralData < AdminDashboardData
   def get_json
+    days_since_update = ((DateTime.now - Discourse.last_commit_date) / 1.day).to_i
     {
-      updated_at: Time.zone.now.as_json
+      updated_at: Time.zone.now.as_json,
+      discourse_updated_at: Discourse.last_commit_date,
+      release_notes_link: "https://meta.discourse.org/c/feature/announcements?tags=release-notes&before=#{days_since_update}"
     }
   end
 
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index b8aa27b..f7bc57c 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -3008,7 +3008,8 @@ en:
 
       dashboard:
         title: "Dashboard"
-        last_updated: "Dashboard last updated:"
+        last_updated: "Dashboard updated:"
+        discourse_last_updated: "Discourse updated:"
         version: "Version"
         up_to_date: "You're up to date!"
         critical_available: "A critical update is available."
diff --git a/lib/discourse.rb b/lib/discourse.rb
index ac91cca..9c2fecc 100644
--- a/lib/discourse.rb
+++ b/lib/discourse.rb
@@ -437,6 +437,16 @@ module Discourse
       end
   end
 
+  def self.last_commit_date
+    ensure_version_file_loaded
+    $last_commit_date ||=
+      begin
+        git_cmd = 'git log -1 --format="%ct"'
+        seconds = self.try_git(git_cmd, nil)
+        seconds.nil? ? nil : DateTime.strptime(seconds, '%s')
+      end
+  end
+
   def self.try_git(git_cmd, default_value)
     version_value = false

GitHub sha: 56663162

1 Like
#2

https://meta.discourse.org/c/feature/announcements?tags=release-notes&before=#{days_since_update}

I wonder if we should add a bit of fudge here cause it can be a bit confusing. This is expecting parity between git times and time stuff is posted on Discourse, which usually is close but not always 100% aligned.

1 Like
#3

I guess we’ll see on our next release.

Approved #4