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

Side by Side Diff: appengine/swarming/server/task_result.py

Issue 2249803003: Create Tasks.Tags endpoint and Cron job (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-py@master
Patch Set: Docs Created 4 years, 4 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/swarming/handlers_test.py ('k') | appengine/swarming/swarming_rpcs.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 831 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 self.state != run_result.state or 842 self.state != run_result.state or
843 self.try_number != run_result.try_number) 843 self.try_number != run_result.try_number)
844 844
845 def to_dict(self): 845 def to_dict(self):
846 out = super(TaskResultSummary, self).to_dict() 846 out = super(TaskResultSummary, self).to_dict()
847 if out['properties_hash']: 847 if out['properties_hash']:
848 out['properties_hash'] = out['properties_hash'].encode('hex') 848 out['properties_hash'] = out['properties_hash'].encode('hex')
849 return out 849 return out
850 850
851 851
852 class TagValues(ndb.Model):
853 tag = ndb.StringProperty()
854 values = ndb.StringProperty(repeated=True)
855
856
857 class TagAggregation(ndb.Model):
858 """Has all dimensions that are currently in use."""
859 tags = ndb.LocalStructuredProperty(TagValues, repeated=True)
860
861 ts = ndb.DateTimeProperty()
862
863 # We only store one of these entities. Use this key to refer to any instance.
864 KEY = ndb.Key('TagAggregation', 'current')
865
866
852 ### Private stuff. 867 ### Private stuff.
853 868
854 869
855 def _run_result_key_to_output_key(run_result_key): 870 def _run_result_key_to_output_key(run_result_key):
856 """Returns a ndb.key to a TaskOutput.""" 871 """Returns a ndb.key to a TaskOutput."""
857 assert run_result_key.kind() == 'TaskRunResult', run_result_key 872 assert run_result_key.kind() == 'TaskRunResult', run_result_key
858 return ndb.Key(TaskOutput, 1, parent=run_result_key) 873 return ndb.Key(TaskOutput, 1, parent=run_result_key)
859 874
860 875
861 def _output_key_to_output_chunk_key(output_key, chunk_number): 876 def _output_key_to_output_chunk_key(output_key, chunk_number):
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
1146 if tags: 1161 if tags:
1147 # Add TaskResultSummary indexes if desired. 1162 # Add TaskResultSummary indexes if desired.
1148 if sort != 'created_ts': 1163 if sort != 'created_ts':
1149 raise ValueError( 1164 raise ValueError(
1150 'Add needed indexes for sort:%s and tags if desired' % sort) 1165 'Add needed indexes for sort:%s and tags if desired' % sort)
1151 tags_filter = TaskResultSummary.tags == tags[0] 1166 tags_filter = TaskResultSummary.tags == tags[0]
1152 for tag in tags[1:]: 1167 for tag in tags[1:]:
1153 tags_filter = ndb.AND(tags_filter, TaskResultSummary.tags == tag) 1168 tags_filter = ndb.AND(tags_filter, TaskResultSummary.tags == tag)
1154 query = query.filter(tags_filter) 1169 query = query.filter(tags_filter)
1155 return _filter_query(TaskResultSummary, query, start, end, sort, state) 1170 return _filter_query(TaskResultSummary, query, start, end, sort, state)
OLDNEW
« no previous file with comments | « appengine/swarming/handlers_test.py ('k') | appengine/swarming/swarming_rpcs.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698