| OLD | NEW |
| 1 # Copyright 2014 The LUCI Authors. All rights reserved. | 1 # Copyright 2014 The LUCI Authors. All rights reserved. |
| 2 # Use of this source code is governed under the Apache License, Version 2.0 | 2 # Use of this source code is governed under the Apache License, Version 2.0 |
| 3 # that can be found in the LICENSE file. | 3 # that can be found in the LICENSE file. |
| 4 | 4 |
| 5 """Task execution result models. | 5 """Task execution result models. |
| 6 | 6 |
| 7 This module doesn't do the scheduling itself. It only describes the entities to | 7 This module doesn't do the scheduling itself. It only describes the entities to |
| 8 store tasks results. | 8 store tasks results. |
| 9 | 9 |
| 10 - TaskResultSummary represents the overall result for the TaskRequest taking in | 10 - TaskResultSummary represents the overall result for the TaskRequest taking in |
| (...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 elif self.state != State.BOT_DIED: | 629 elif self.state != State.BOT_DIED: |
| 630 # With BOT_DIED, it can be either ways. | 630 # With BOT_DIED, it can be either ways. |
| 631 if self.duration is not None: | 631 if self.duration is not None: |
| 632 raise datastore_errors.BadValueError( | 632 raise datastore_errors.BadValueError( |
| 633 'duration and exit_code must not be set with state %s' % | 633 'duration and exit_code must not be set with state %s' % |
| 634 State.to_string(self.state)) | 634 State.to_string(self.state)) |
| 635 | 635 |
| 636 if self.deduped_from: | 636 if self.deduped_from: |
| 637 if self.state != State.COMPLETED: | 637 if self.state != State.COMPLETED: |
| 638 raise datastore_errors.BadValueError( | 638 raise datastore_errors.BadValueError( |
| 639 'state must be COMPLETED on deduped task') | 639 'state(%d) must be COMPLETED on deduped task %s' % |
| 640 (self.state, self.deduped_from)) |
| 640 if self.failure: | 641 if self.failure: |
| 641 raise datastore_errors.BadValueError( | 642 raise datastore_errors.BadValueError( |
| 642 'failure can\'t be True on deduped task') | 643 'failure can\'t be True on deduped task %s' % self.deduped_from) |
| 643 | 644 |
| 644 self.children_task_ids = sorted( | 645 self.children_task_ids = sorted( |
| 645 set(self.children_task_ids), key=lambda x: int(x, 16)) | 646 set(self.children_task_ids), key=lambda x: int(x, 16)) |
| 646 | 647 |
| 647 @classmethod | 648 @classmethod |
| 648 def _properties_fixed(cls): | 649 def _properties_fixed(cls): |
| 649 """Returns all properties with their member name, excluding computed | 650 """Returns all properties with their member name, excluding computed |
| 650 properties. | 651 properties. |
| 651 """ | 652 """ |
| 652 return [ | 653 return [ |
| (...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1202 if tags: | 1203 if tags: |
| 1203 # Add TaskResultSummary indexes if desired. | 1204 # Add TaskResultSummary indexes if desired. |
| 1204 if sort != 'created_ts': | 1205 if sort != 'created_ts': |
| 1205 raise ValueError( | 1206 raise ValueError( |
| 1206 'Add needed indexes for sort:%s and tags if desired' % sort) | 1207 'Add needed indexes for sort:%s and tags if desired' % sort) |
| 1207 tags_filter = TaskResultSummary.tags == tags[0] | 1208 tags_filter = TaskResultSummary.tags == tags[0] |
| 1208 for tag in tags[1:]: | 1209 for tag in tags[1:]: |
| 1209 tags_filter = ndb.AND(tags_filter, TaskResultSummary.tags == tag) | 1210 tags_filter = ndb.AND(tags_filter, TaskResultSummary.tags == tag) |
| 1210 query = query.filter(tags_filter) | 1211 query = query.filter(tags_filter) |
| 1211 return _filter_query(TaskResultSummary, query, start, end, sort, state) | 1212 return _filter_query(TaskResultSummary, query, start, end, sort, state) |
| OLD | NEW |