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

Unified Diff: appengine/chromium_try_flakes/status/util.py

Issue 1660043002: Move flaky run processing into a taskqueue (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Added new files Created 4 years, 11 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_try_flakes/status/util.py
diff --git a/appengine/chromium_try_flakes/status/util.py b/appengine/chromium_try_flakes/status/util.py
new file mode 100644
index 0000000000000000000000000000000000000000..da03496045ddedefcc7543be1c30a0e38cecd44d
--- /dev/null
+++ b/appengine/chromium_try_flakes/status/util.py
@@ -0,0 +1,41 @@
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Utility functions for handling flakes."""
Sergiy Byelozyorov 2016/02/02 21:27:27 This is copied from stats/cq_status.py. If kept th
tandrii(chromium) 2016/02/02 21:54:18 yeah, new file is LGTM.
+
+import datetime
+
+
+def is_last_hour(date):
+ return (datetime.datetime.utcnow() - date) < datetime.timedelta(hours=1)
+
+
+def is_last_day(date):
+ return (datetime.datetime.utcnow() - date) < datetime.timedelta(days=1)
+
+
+def is_last_week(date):
+ return (datetime.datetime.utcnow() - date) < datetime.timedelta(weeks=1)
+
+
+def is_last_month(date):
+ return (datetime.datetime.utcnow() - date) < datetime.timedelta(days=31)
+
+
+def add_occurrence_time_to_flake(flake, occurrence_time):
+ if occurrence_time > flake.last_time_seen:
+ flake.last_time_seen = occurrence_time
+ if is_last_hour(occurrence_time):
+ flake.count_hour += 1
+ flake.last_hour = True
+ if is_last_day(occurrence_time):
+ flake.count_day += 1
+ flake.last_day = True
+ if is_last_week(occurrence_time):
+ flake.count_week += 1
+ flake.last_week = True
+ if is_last_month(occurrence_time):
+ flake.count_month += 1
+ flake.last_month = True
+ flake.count_all += 1

Powered by Google App Engine
This is Rietveld 408576698