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

Unified Diff: appengine/chromium_cq_status/model/record.py

Issue 515093004: chromium-cq-status: StatsTest utility class for testing CQ stats (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Rebase Created 6 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 side-by-side diff with in-line comments
Download patch
Index: appengine/chromium_cq_status/model/record.py
diff --git a/appengine/chromium_cq_status/model/record.py b/appengine/chromium_cq_status/model/record.py
index 33c55c5373d15f00dd122230fd011c9109326c0f..899248e36f9b2c7375fb826a706f5ea81471fd22 100644
--- a/appengine/chromium_cq_status/model/record.py
+++ b/appengine/chromium_cq_status/model/record.py
@@ -2,9 +2,19 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+from shared.utils import to_unix_timestamp
+
from google.appengine.ext import ndb
-class Record(ndb.Model):
+class Record(ndb.Model): # pragma: no cover
timestamp = ndb.DateTimeProperty(auto_now=True)
tags = ndb.StringProperty(repeated=True)
fields = ndb.JsonProperty(default={})
+
+ def to_dict(self):
+ return {
+ 'key': self.key.id() if type(self.key.id()) != long else None,
+ 'timestamp': to_unix_timestamp(self.timestamp),
+ 'tags': self.tags,
+ 'fields': self.fields,
+ }
« no previous file with comments | « appengine/chromium_cq_status/handlers/query.py ('k') | appengine/chromium_cq_status/tests/resources/test_load_records.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698