Эх сурвалжийг харах

[jb] Avoid javascript error when application does not have a valid time

In particular having a non numeric for startedTime will create a
TypeError: Cannot read property '1' of null
Romain Rigaux 10 жил өмнө
parent
commit
2e243c6

+ 4 - 4
apps/jobbrowser/src/jobbrowser/views.py

@@ -159,14 +159,14 @@ def massage_job_for_json(job, request):
     'finishedReduces': job.finishedReduces,
     'finishedReduces': job.finishedReduces,
     'reducesPercentComplete': int(job.reduces_percent_complete) if job.reduces_percent_complete else '',
     'reducesPercentComplete': int(job.reduces_percent_complete) if job.reduces_percent_complete else '',
     'jobFile': hasattr(job, 'jobFile') and job.jobFile or '',
     'jobFile': hasattr(job, 'jobFile') and job.jobFile or '',
-    'launchTimeMs': hasattr(job, 'launchTimeMs') and job.launchTimeMs or '',
+    'launchTimeMs': hasattr(job, 'launchTimeMs') and job.launchTimeMs or 0,
     'launchTimeFormatted': hasattr(job, 'launchTimeFormatted') and job.launchTimeFormatted or '',
     'launchTimeFormatted': hasattr(job, 'launchTimeFormatted') and job.launchTimeFormatted or '',
-    'startTimeMs': hasattr(job, 'startTimeMs') and job.startTimeMs or '',
+    'startTimeMs': hasattr(job, 'startTimeMs') and job.startTimeMs or 0,
     'startTimeFormatted': hasattr(job, 'startTimeFormatted') and job.startTimeFormatted or '',
     'startTimeFormatted': hasattr(job, 'startTimeFormatted') and job.startTimeFormatted or '',
-    'finishTimeMs': hasattr(job, 'finishTimeMs') and job.finishTimeMs or '',
+    'finishTimeMs': hasattr(job, 'finishTimeMs') and job.finishTimeMs or 0,
     'finishTimeFormatted': hasattr(job, 'finishTimeFormatted') and job.finishTimeFormatted or '',
     'finishTimeFormatted': hasattr(job, 'finishTimeFormatted') and job.finishTimeFormatted or '',
     'durationFormatted': hasattr(job, 'durationFormatted') and job.durationFormatted or '',
     'durationFormatted': hasattr(job, 'durationFormatted') and job.durationFormatted or '',
-    'durationMs': hasattr(job, 'durationInMillis') and job.durationInMillis or '',
+    'durationMs': hasattr(job, 'durationInMillis') and job.durationInMillis or 0,
     'canKill': can_kill_job(job, request.user),
     'canKill': can_kill_job(job, request.user),
     'killUrl': job.jobId and reverse('jobbrowser.views.kill_job', kwargs={'job': job.jobId}) or ''
     'killUrl': job.jobId and reverse('jobbrowser.views.kill_job', kwargs={'job': job.jobId}) or ''
   }
   }

+ 2 - 2
apps/jobbrowser/src/jobbrowser/yarn_models.py

@@ -66,8 +66,8 @@ class Application(object):
       finishTime = self.finishedTime
       finishTime = self.finishedTime
     setattr(self, 'durationInMillis', finishTime - self.startedTime)
     setattr(self, 'durationInMillis', finishTime - self.startedTime)
     setattr(self, 'startTimeMs', self.startedTime)
     setattr(self, 'startTimeMs', self.startedTime)
-    setattr(self, 'startTimeFormatted',  format_unixtime_ms(self.startedTime))
-    setattr(self, 'finishTimeFormatted',  format_unixtime_ms(finishTime))
+    setattr(self, 'startTimeFormatted', format_unixtime_ms(self.startedTime))
+    setattr(self, 'finishTimeFormatted', format_unixtime_ms(finishTime))
     setattr(self, 'finishedMaps', None)
     setattr(self, 'finishedMaps', None)
     setattr(self, 'desiredMaps', None)
     setattr(self, 'desiredMaps', None)
     setattr(self, 'finishedReduces', None)
     setattr(self, 'finishedReduces', None)