amol- commented on a change in pull request #10650:
URL: https://github.com/apache/arrow/pull/10650#discussion_r667775868



##########
File path: dev/archery/archery/crossbow/reports.py
##########
@@ -160,6 +160,29 @@ def url(self, query):
         repo_url = self.job.queue.remote_url.strip('.git')
         return '{}/branches/all?query={}'.format(repo_url, query)
 
+    def todayStr(self):
+        date = datetime.utcnow()
+        return "{}-{}-{}".format(date.year, date.month, date.day)
+
+    def tasksToDict(self, date, tasks):
+        jsonTasks = []
+        for task_name, task in tasks.items():
+            jsonTasks.append({
+                "build" : task_name,
+                "link" : self.url(task.branch),
+                "status" : task.status().combined_state.upper(),
+                "timestamp" : date})
+
+        return jsonTasks
+
+    def getJsonTasks(self):
+        tasks = self.tasksToDict(self.todayStr(), self.job.tasks.items())
+        jsonStr = json.dump(tasks)
+        #TODO remove the print
+        print(jsonStr)

Review comment:
       I think, now that we have the state, that we want to move it to its own 
command (as stated in https://issues.apache.org/jira/browse/ARROW-13059).
   
   At the moment you are invoking "tasksToDict" and printing it inside the 
`EmailReport` class, whose only purpose is to send the report by email when the 
`archery crossbow report` command is invoked.
   
   Instead the ticket requires to create a new command `archery crossbow 
save-report-data` which does the job.
   
   So I think that we should probably move those new functions into their own 
command inside of 
https://github.com/apache/arrow/blob/master/dev/archery/archery/crossbow/cli.py
   
   Mostly you can copy the `report` command ( 
https://github.com/apache/arrow/blob/master/dev/archery/archery/crossbow/cli.py#L236-L296
 ) remove most parameters, and just print there the state of the `job` (No need 
to even involve the `EmailReport` at all)

##########
File path: dev/archery/archery/crossbow/reports.py
##########
@@ -160,6 +160,29 @@ def url(self, query):
         repo_url = self.job.queue.remote_url.strip('.git')
         return '{}/branches/all?query={}'.format(repo_url, query)
 
+    def todayStr(self):
+        date = datetime.utcnow()
+        return "{}-{}-{}".format(date.year, date.month, date.day)
+
+    def tasksToDict(self, date, tasks):
+        jsonTasks = []
+        for task_name, task in tasks.items():
+            jsonTasks.append({
+                "build" : task_name,
+                "link" : self.url(task.branch),
+                "status" : task.status().combined_state.upper(),
+                "timestamp" : date})
+
+        return jsonTasks
+
+    def getJsonTasks(self):
+        tasks = self.tasksToDict(self.todayStr(), self.job.tasks.items())
+        jsonStr = json.dump(tasks)
+        #TODO remove the print
+        print(jsonStr)

Review comment:
       FYI, here is also where we should attach the next command -> 
https://github.com/ursacomputing/crossbow/blob/master/.github/workflows/nightly_report.yml#L36-L43
   
   before the "Sending ..." line ( 
https://github.com/ursacomputing/crossbow/blob/master/.github/workflows/nightly_report.yml#L35
 ) we probably want to "save" the report.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to