Skip to content

Commit

Permalink
format datetimes (#38)
Browse files Browse the repository at this point in the history
* format datetimes

fix next_run update after toggle schedule active

* use moment-timezone to lock the timezone in tests
  • Loading branch information
aclowes authored Jun 3, 2018
1 parent 88ab7b6 commit 59b42ff
Show file tree
Hide file tree
Showing 15 changed files with 57 additions and 18 deletions.
2 changes: 2 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
"dependencies": {
"bootswatch": "^3.3.7",
"dagre-d3": "^0.4.17",
"moment": "^2.22.2",
"moment-timezone": "^0.5.17",
"react": "^15.6.1",
"react-bootstrap": "^0.30.10",
"react-dom": "^15.6.1",
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/ExecutionTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import React from 'react';
import {Table} from 'react-bootstrap';
import {Link} from 'react-router';

import {formatDateTime} from "./utilities";


export default class ExecutionTable extends React.Component {

Expand All @@ -19,7 +21,7 @@ export default class ExecutionTable extends React.Component {
<td>{execution.task.workflow && execution.task.workflow.name}</td>
<td><Link to={`/tasks/${execution.task.id}`}>{execution.task.name}</Link></td>
<td>{execution.status}</td>
<td>{execution.start_timestamp}</td>
<td>{formatDateTime(execution.start_timestamp)}</td>
<td>{execution.minutes_running}</td>
</tr>
))
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/TaskDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {PanelGroup, Panel, Alert, Pagination, Button} from 'react-bootstrap';
import {Link} from 'react-router';

import API from "./API";
import {formatDateTime} from "./utilities";

export default class TaskDetail extends React.Component {
constructor(props) {
Expand Down Expand Up @@ -92,9 +93,9 @@ export default class TaskDetail extends React.Component {
</Link>
</dd>
<dt>Start Time</dt>
<dd>{execution.start_timestamp}</dd>
<dd>{formatDateTime(execution.start_timestamp)}</dd>
<dt>Stop Time</dt>
<dd>{execution.stop_timestamp}</dd>
<dd>{formatDateTime(execution.stop_timestamp)}</dd>
<dt>Exit Code</dt>
<dd>{execution.exit_code}</dd>
<dt>Standard Output</dt>
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/WorkerDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {Panel, PanelGroup, Alert} from 'react-bootstrap';

import API from "./API";
import ExecutionTable from "./ExecutionTable";
import {formatDateTime} from "./utilities";

export default class WorkerDetail extends React.Component {
constructor(props) {
Expand Down Expand Up @@ -36,9 +37,9 @@ export default class WorkerDetail extends React.Component {
<dt>Status</dt>
<dd>{worker.status}</dd>
<dt>Start Timestamp</dt>
<dd>{worker.start_timestamp}</dd>
<dd>{formatDateTime(worker.start_timestamp)}</dd>
<dt>Last Heartbeat</dt>
<dd>{worker.last_heartbeat}</dd>
<dd>{formatDateTime(worker.last_heartbeat)}</dd>
</dl>
</Panel>
<Panel header="Executions">
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/WorkerList.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {Table, Alert} from 'react-bootstrap';
import {Link} from 'react-router';

import API from "./API";
import {formatDateTime} from "./utilities";

export default class WorkerList extends React.Component {
constructor(props) {
Expand Down Expand Up @@ -30,8 +31,8 @@ export default class WorkerList extends React.Component {
<tr key={worker.id}>
<td><Link to={`/workers/${worker.id}`}>{worker.name}</Link></td>
<td>{worker.status}</td>
<td>{worker.start_timestamp}</td>
<td>{worker.last_heartbeat}</td>
<td>{formatDateTime(worker.start_timestamp)}</td>
<td>{formatDateTime(worker.last_heartbeat)}</td>
</tr>
)
})
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/WorkflowDetailForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
} from 'react-bootstrap';

import API from './API'
import {formatDateTime} from "./utilities";

/* Helper to extract form values from a given object */
function formValues(object) {
Expand All @@ -26,6 +27,7 @@ function formValues(object) {
schedule: object.schedule,
schedule_active: object.schedule_active,
parameters: parameters,
next_run: object.next_run,
}
}

Expand Down Expand Up @@ -122,7 +124,7 @@ export default class WorkflowDetailForm extends React.Component {
<dt>Schedule</dt>
<dd>{this.state.schedule}</dd>
<dt>Next Run</dt>
<dd>{this.props.workflow.next_run}</dd>
<dd>{formatDateTime(this.state.next_run)}</dd>
<dt>Parameters</dt>
<dd>
<pre>{this.state.parameters}</pre>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ exports[`ExecutionList success 1`] = `
succeeded
</td>
<td>
2017-01-30T04:17:47.008524Z
January 30th 2017, 4:17:47 am
</td>
<td>
0m 0.05s
Expand Down
6 changes: 4 additions & 2 deletions frontend/src/tests/__snapshots__/TaskDetail.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,14 @@ exports[`TaskDetail success 1`] = `
Start Time
</dt>
<dd>
2017-01-30T03:26:38.211839Z
January 30th 2017, 3:26:38 am
</dd>
<dt>
Stop Time
</dt>
<dd />
<dd>
</dd>
<dt>
Exit Code
</dt>
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/tests/__snapshots__/WorkerDetail.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ exports[`WorkerDetail success 1`] = `
Start Timestamp
</dt>
<dd>
2017-01-30T04:13:47.966080Z
January 30th 2017, 4:13:47 am
</dd>
<dt>
Last Heartbeat
</dt>
<dd>
2017-01-30T04:15:10.845289Z
January 30th 2017, 4:15:10 am
</dd>
</dl>
</div>
Expand Down Expand Up @@ -126,7 +126,7 @@ exports[`WorkerDetail success 1`] = `
succeeded
</td>
<td>
2017-01-30T04:17:03.806599Z
January 30th 2017, 4:17:03 am
</td>
<td />
</tr>
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/tests/__snapshots__/WorkerList.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ exports[`WorkerList success 1`] = `
exited
</td>
<td>
2017-01-30T04:13:47.966080Z
January 30th 2017, 4:13:47 am
</td>
<td>
2017-01-30T04:15:10.845289Z
January 30th 2017, 4:15:10 am
</td>
</tr>
</tbody>
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/tests/__snapshots__/WorkflowDetail.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ exports[`WorkflowDetail success 1`] = `
<dt>
Next Run
</dt>
<dd />
<dd>
</dd>
<dt>
Parameters
</dt>
Expand Down
8 changes: 8 additions & 0 deletions frontend/src/tests/mocks.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import moment from "moment-timezone";

import API from '../API';

/*
* Set the timezone to UTC when running tests, for consistent
* snapshots.
* */
moment.tz.setDefault('UTC');

/*
Mock API with canned responses; it will call the callback
immediately instead of waiting for a Promise. This means
Expand Down
8 changes: 8 additions & 0 deletions frontend/src/utilities.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import moment from "moment";

export function formatDateTime(datetime) {
if (!datetime) {
return '';
}
return moment(datetime).format('MMMM Do YYYY, h:mm:ss a');
}
10 changes: 10 additions & 0 deletions frontend/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4058,6 +4058,16 @@ [email protected], [email protected], "mkdirp@>=0.5 0", mkdirp@^0.5.0, mkdirp@^0.5.1, mkdi
dependencies:
minimist "0.0.8"

moment-timezone@^0.5.17:
version "0.5.17"
resolved "https://registry.yarnpkg.com/moment-timezone/-/moment-timezone-0.5.17.tgz#3c8fef32051d84c3af174d91dc52977dcb0ad7e5"
dependencies:
moment ">= 2.9.0"

"moment@>= 2.9.0", moment@^2.22.2:
version "2.22.2"
resolved "https://registry.yarnpkg.com/moment/-/moment-2.22.2.tgz#3c257f9839fc0e93ff53149632239eb90783ff66"

[email protected]:
version "0.7.1"
resolved "https://registry.yarnpkg.com/ms/-/ms-0.7.1.tgz#9cd13c03adbff25b65effde7ce864ee952017098"
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
# Versions should comply with PEP440. For a discussion on single-sourcing
# the version across setup.py and the project code, see
# https://packaging.python.org/en/latest/single_source_version.html
version='0.2.2',
version='0.2.3',

description='Yet Another Workflow Engine, a subprocess-based DAG execution system',
long_description=long_description,
Expand Down

0 comments on commit 59b42ff

Please sign in to comment.