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

Side by Side Diff: appengine/findit/model/flake/flake_swarming_task_result.py

Issue 2124973003: These are the database objects used while finding the regression range. 1/3 (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
OLDNEW
(Empty)
1 # Copyright 2014 The Chromium Authors. All rights reserved.
chanli 2016/07/07 23:38:28 2014 -> 2016
caiw 2016/07/14 00:59:40 Done.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 from google.appengine.ext import ndb
6
7 from common import constants
8 from model import analysis_status
9
10 class FlakeSwarmingTaskResult(ndb.Model):
11 """Results of a swarming task for a single suspected flaky test.
12 """
13
14 @staticmethod
15 def CreateAnalysisId(master_name, builder_name,
16 step_name, build_number, testname): # pragma: no cover
chanli 2016/07/07 23:38:28 nit: I would use test_name instead of testname
caiw 2016/07/14 00:59:40 Done.
17 return '%s/%s/%s/%s/%s' % (master_name, builder_name,
18 step_name, build_number, testname)
19
20 @staticmethod
21 def _CreateKey(master_name, builder_name,
22 step_name, build_number, testname): # pragma: no cover
23 return ndb.Key('FlakeSwarmingTaskResult',
24 FlakeSwarmingTaskResult.CreateAnalysisId(
25 master_name, builder_name, step_name,
26 build_number, testname))
27
28 @staticmethod
29 def Create(master_name, builder_name,
30 step_name, build_number, testname): # pragma: no cover
31 return FlakeSwarmingTaskResult(key=FlakeSwarmingTaskResult._CreateKey(
32 master_name, builder_name, step_name, build_number, testname))
33
34 @staticmethod
35 def Get(master_name, builder_name,
36 step_name, build_number, testname): # pragma: no cover
37 return FlakeSwarmingTaskResult._CreateKey(
38 master_name, builder_name, step_name, build_number, testname).get()
39
40
41 @property
42 def completed(self):
43 return self.status in (
44 analysis_status.COMPLETED, analysis_status.ERROR)
45
46 @property
47 def failed(self):
48 return self.status == analysis_status.ERROR
49
50 @property
51 def status_description(self):
52 return analysis_status.STATUS_TO_DESCRIPTION.get(self.status, 'Unknown')
53
54 @ndb.ComputedProperty
55 def master_name(self):
56 return self.key.pairs()[0][1].split('/')[0]
stgao 2016/07/08 22:51:27 As we discussed, some code here could be cleaned u
caiw 2016/07/14 00:59:40 Done.
57
58 @ndb.ComputedProperty
59 def builder_name(self):
60 return self.key.pairs()[0][1].split('/')[1]
61
62 @ndb.ComputedProperty
63 def step_name(self):
64 return self.key.pairs()[0][1].split('/')[2]
65
66 @ndb.ComputedProperty
67 def build_number(self):
68 return int(self.key.pairs()[0][1].split('/')[3])
69
70 @ndb.ComputedProperty
71 def test_name(self):
72 return self.key.pairs()[0][1].split('/')[4]
73
74
chanli 2016/07/07 23:38:28 Same here: please add comments.
caiw 2016/07/14 00:59:40 Done.
75 status = ndb.IntegerProperty(default=analysis_status.PENDING, indexed=False)
76 successes = ndb.IntegerProperty(default=0, indexed=False)
77 tries = ndb.IntegerProperty(default=0, indexed=False)
78 git_hash = ndb.StringProperty(indexed=False)
79 commit_position = ndb.IntegerProperty(indexed=False)
80 master_name = ndb.StringProperty(indexed=False)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698