Skip to content

Commit

Permalink
add duration to run JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesturk committed Mar 18, 2020
1 parent f181673 commit 14eb7aa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
11 changes: 11 additions & 0 deletions bobsled/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 126,20 @@ async def index(request):
return templates.TemplateResponse("base.html", {"request": request})


def _parse_time(time):
return datetime.datetime.strptime(time, "%Y-%m-%dT%H:%M:%S.%f")


def _run2dict(run):
run = attr.asdict(run)
run["status"] = run["status"].name
if run["end"]:
tdelta = _parse_time(run["end"]) - _parse_time(run["start"])
hour, rem = divmod(tdelta.seconds, 3600)
minutes, seconds = divmod(rem, 60)
run["duration"] = f"{hour}:{minutes:02d}:{seconds:02d}"
else:
run["duration"] = ""
return run


Expand Down
2 changes: 2 additions & 0 deletions js/RunList.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 25,7 @@ function RunList(props) {
)}
{statusCol(run.status)}
<td>{formatTime(run.end)}</td>
<td>{run.duration}</td>
</tr>
));

Expand All @@ -38,6 39,7 @@ function RunList(props) {
{props.hideTask === "true" ? null : <th>Task</th>}
<th>Status</th>
<th>End Time</th>
<th>Duration</th>
</tr>
</thead>
<tbody>{rows}</tbody>
Expand Down

0 comments on commit 14eb7aa

Please sign in to comment.