← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~ilasc/launchpad:add-link-to-status-report-log into launchpad:master

 

Ioana Lasc has proposed merging ~ilasc/launchpad:add-link-to-status-report-log into launchpad:master.

Commit message:
Add link to latest internal log of status reports

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~ilasc/launchpad/+git/launchpad/+merge/417156

This adds the link to the latest internally stored log on status reports. 

We use the URL to the log as a fallback if report.url isn't set instead of defining a new column in the table and we only link to the internally-stored log when we don't have an external URL.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~ilasc/launchpad:add-link-to-status-report-log into launchpad:master.
diff --git a/lib/lp/code/interfaces/revisionstatus.py b/lib/lp/code/interfaces/revisionstatus.py
index 8dcb2e4..3a33384 100644
--- a/lib/lp/code/interfaces/revisionstatus.py
+++ b/lib/lp/code/interfaces/revisionstatus.py
@@ -91,6 +91,9 @@ class IRevisionStatusReportView(Interface):
         :param artifact_type: The type of artifact for the report.
         """
 
+    def latestLog():
+        """Retrieves the URL for the most recent log for this report."""
+
 
 class IRevisionStatusReportEditableAttributes(Interface):
     """`IRevisionStatusReport` attributes that can be edited.
diff --git a/lib/lp/code/model/revisionstatus.py b/lib/lp/code/model/revisionstatus.py
index 1f74af3..302aca3 100644
--- a/lib/lp/code/model/revisionstatus.py
+++ b/lib/lp/code/model/revisionstatus.py
@@ -11,6 +11,7 @@ import io
 import os
 
 import pytz
+from storm.expr import Desc
 from storm.locals import (
     And,
     DateTime,
@@ -157,6 +158,19 @@ class RevisionStatusReport(StormBase):
         artifacts = IStore(RevisionStatusArtifact).find(*clauses)
         return [artifact.download_url for artifact in artifacts]
 
+    def latestLog(self):
+        file_object = IStore(RevisionStatusArtifact).find(
+            RevisionStatusArtifact,
+            RevisionStatusArtifact.report == self,
+            LibraryFileAlias.id == RevisionStatusArtifact.library_file_id
+        ).order_by(Desc(LibraryFileAlias.date_created)).first()
+
+        if self.url:
+            return self.url
+        else:
+            if file_object:
+                return file_object.download_url
+
 
 @implementer(IRevisionStatusReportSet)
 class RevisionStatusReportSet:
diff --git a/lib/lp/code/templates/git-macros.pt b/lib/lp/code/templates/git-macros.pt
index a990c18..46fa026 100644
--- a/lib/lp/code/templates/git-macros.pt
+++ b/lib/lp/code/templates/git-macros.pt
@@ -235,7 +235,7 @@
           <tbody>
             <tr tal:repeat="report batch">
               <td tal:content="structure report/result/enumvalue:SUCCEEDED/image:boolean" />
-              <td><a tal:attributes="href report/url|nothing" tal:content="report/title" /></td>
+              <td><a tal:attributes="href report/latestLog|nothing" tal:content="report/title" /></td>
               <td tal:content="report/result_summary" />
             </tr>
           </tbody>

Follow ups