summaryrefslogtreecommitdiff
path: root/zuul/web
diff options
context:
space:
mode:
authorJames E. Blair <jim@acmegating.com>2022-02-15 09:14:49 -0800
committerJames E. Blair <jim@acmegating.com>2022-02-23 06:24:04 -0800
commit8f9b99dc7bd4b03b4fb46ea6e065067e99f7247c (patch)
treea6865f8fb6ea18424b65ac4d2566b332c47a552f /zuul/web
parentd5385d7fc58f98d719ebe981e053ff12e639aed6 (diff)
downloadzuul-8f9b99dc7bd4b03b4fb46ea6e065067e99f7247c.tar.gz
Add buildset start/end db columns
Add two columns to the buildset table in the database: the timestamp of the start of the first build and the end of the last build. These are calculated from the builds in the webui buildset page, but they are not available in the buildset listing without performing a table join on the server side. To keep the buildset query simple and fast, this adds the columns to the buildset table (which is a minor data duplication). Return the new values in the rest api. Change-Id: Ie162e414ed5cf09e9dc8f5c92e07b80934592fdf
Diffstat (limited to 'zuul/web')
-rwxr-xr-xzuul/web/__init__.py24
1 files changed, 11 insertions, 13 deletions
diff --git a/zuul/web/__init__.py b/zuul/web/__init__.py
index a3f7dcbcc..7cf738a58 100755
--- a/zuul/web/__init__.py
+++ b/zuul/web/__init__.py
@@ -1286,15 +1286,13 @@ class ZuulWebAPI(object):
return key
def _datetimeToString(self, my_datetime):
- return my_datetime.strftime('%Y-%m-%dT%H:%M:%S')
+ if my_datetime:
+ return my_datetime.strftime('%Y-%m-%dT%H:%M:%S')
+ return None
def buildToDict(self, build, buildset=None):
- start_time = build.start_time
- if build.start_time:
- start_time = self._datetimeToString(start_time)
- end_time = build.end_time
- if build.end_time:
- end_time = self._datetimeToString(end_time)
+ start_time = self._datetimeToString(build.start_time)
+ end_time = self._datetimeToString(build.end_time)
if build.start_time and build.end_time:
duration = (build.end_time -
build.start_time).total_seconds()
@@ -1320,9 +1318,7 @@ class ZuulWebAPI(object):
}
if buildset:
- event_timestamp = buildset.event_timestamp
- if event_timestamp:
- event_timestamp = self._datetimeToString(event_timestamp)
+ event_timestamp = self._datetimeToString(buildset.event_timestamp)
ret.update({
'project': buildset.project,
'branch': buildset.branch,
@@ -1408,9 +1404,9 @@ class ZuulWebAPI(object):
return data
def buildsetToDict(self, buildset, builds=[]):
- event_timestamp = buildset.event_timestamp
- if event_timestamp:
- event_timestamp = self._datetimeToString(event_timestamp)
+ event_timestamp = self._datetimeToString(buildset.event_timestamp)
+ start = self._datetimeToString(buildset.first_build_start_time)
+ end = self._datetimeToString(buildset.last_build_end_time)
ret = {
'_id': buildset.id,
'uuid': buildset.uuid,
@@ -1426,6 +1422,8 @@ class ZuulWebAPI(object):
'ref_url': buildset.ref_url,
'event_id': buildset.event_id,
'event_timestamp': event_timestamp,
+ 'first_build_start_time': start,
+ 'last_build_end_time': end,
}
if builds:
ret['builds'] = []