Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(247)

Side by Side Diff: appengine/findit/model/wf_try_job.py

Issue 2147713002: [Findit] Make sure not use empty list or dict as default value. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: . Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « appengine/findit/model/wf_swarming_task.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 from google.appengine.ext import ndb 5 from google.appengine.ext import ndb
6 6
7 from model.base_build_model import BaseBuildModel 7 from model.base_build_model import BaseBuildModel
8 from model import analysis_status 8 from model import analysis_status
9 9
10 10
11 class WfTryJob(BaseBuildModel): 11 class WfTryJob(BaseBuildModel):
12 """Represents a try job results for a failed build. 12 """Represents a try job results for a failed build.
13 13
14 'Wf' is short for waterfall. 14 'Wf' is short for waterfall.
15 """ 15 """
16 # A list of dict containing results and urls of each try job for compile. 16 # A list of dict containing results and urls of each try job for compile.
17 compile_results = ndb.JsonProperty(default=[], indexed=False, compressed=True) 17 compile_results = ndb.JsonProperty(indexed=False, compressed=True)
18 18
19 # A list of dict containing results and urls of each try job for test. 19 # A list of dict containing results and urls of each try job for test.
20 test_results = ndb.JsonProperty(default=[], indexed=False, compressed=True) 20 test_results = ndb.JsonProperty(indexed=False, compressed=True)
21 21
22 # The status of the try job. 22 # The status of the try job.
23 status = ndb.IntegerProperty( 23 status = ndb.IntegerProperty(
24 default=analysis_status.PENDING, indexed=False) 24 default=analysis_status.PENDING, indexed=False)
25 25
26 # A list of try job IDs associated with each try job for collecting metadata. 26 # A list of try job IDs associated with each try job for collecting metadata.
27 try_job_ids = ndb.JsonProperty(default=[], indexed=False, compressed=True) 27 try_job_ids = ndb.JsonProperty(indexed=False, compressed=True)
28 28
29 @staticmethod 29 @staticmethod
30 def _CreateKey(master_name, builder_name, build_number): # pragma: no cover 30 def _CreateKey(master_name, builder_name, build_number): # pragma: no cover
31 return ndb.Key('WfTryJob', 31 return ndb.Key('WfTryJob',
32 BaseBuildModel.CreateBuildId( 32 BaseBuildModel.CreateBuildId(
33 master_name, builder_name, build_number)) 33 master_name, builder_name, build_number))
34 34
35 @staticmethod 35 @staticmethod
36 def Create(master_name, builder_name, build_number): # pragma: no cover 36 def Create(master_name, builder_name, build_number): # pragma: no cover
37 return WfTryJob( 37 try_job = WfTryJob(
38 key=WfTryJob._CreateKey(master_name, builder_name, build_number)) 38 key=WfTryJob._CreateKey(master_name, builder_name, build_number))
39 try_job.compile_results = try_job.compile_results or []
40 try_job.test_results = try_job.test_results or []
41 try_job.try_job_ids = try_job.try_job_ids or []
42 return try_job
39 43
40 @staticmethod 44 @staticmethod
41 def Get(master_name, builder_name, build_number): # pragma: no cover 45 def Get(master_name, builder_name, build_number): # pragma: no cover
42 return WfTryJob._CreateKey( 46 return WfTryJob._CreateKey(
43 master_name, builder_name, build_number).get() 47 master_name, builder_name, build_number).get()
44 48
45 @property 49 @property
46 def completed(self): 50 def completed(self):
47 return self.status in ( 51 return self.status in (
48 analysis_status.COMPLETED, analysis_status.ERROR) 52 analysis_status.COMPLETED, analysis_status.ERROR)
49 53
50 @property 54 @property
51 def failed(self): 55 def failed(self):
52 return self.status == analysis_status.ERROR 56 return self.status == analysis_status.ERROR
OLDNEW
« no previous file with comments | « appengine/findit/model/wf_swarming_task.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698