Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/sentry/event_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ def _save_aggregate(self, event, hashes, **kwargs):
tsdb.incr_multi([
(tsdb.models.group, group.id),
(tsdb.models.project, project.id),
])
], timestamp=event.datetime)

return group, is_new, is_regression, is_sample

Expand Down
48 changes: 34 additions & 14 deletions src/sentry/static/sentry/app/components/timeSince.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ var TimeSince = React.createClass({
PureRenderMixin
],

statics: {
getDateObj(date) {
if (typeof date === "string" || typeof date === "number") {
date = new Date(date);
}
return date;
}
},

propTypes: {
date: React.PropTypes.any.isRequired,
suffix: React.PropTypes.string
Expand All @@ -18,35 +27,46 @@ var TimeSince = React.createClass({
};
},

getInitialState() {
return {
relative: this.getRelativeDate()
};
},

componentDidMount() {
var delay = 2600;
this.setRelativeDateTicker();
},

this.ticker = setInterval(this.ensureValidity, delay);
setRelativeDateTicker() {
const ONE_MINUTE_IN_MS = 3600;

this.ticker = setTimeout(() => {
this.setState({
relative: this.getRelativeDate()
});
this.setRelativeDateTicker();
}, ONE_MINUTE_IN_MS);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesnt this mean 1s doesnt update until its 61s?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's true (it was doing that before, too, except every 43 secs).

We should make the timeout according to the duration of the relative time. Follow-up?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah i guess thats true, dont know why it was 2600

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kind of just assumed it was a mistake and 3600 was intended.

},

getRelativeDate() {
let date = TimeSince.getDateObj(this.props.date);
return moment(date).fromNow(true);
},

componentWillUnmount() {
if (this.ticker) {
clearInterval(this.ticker);
clearTimeout(this.ticker);
this.ticker = null;
}
},

ensureValidity() {
// TODO(dcramer): this should ensure we actually *need* to update the value
this.forceUpdate();
},

render() {
var date = this.props.date;

if (typeof date === "string" || typeof date === "number") {
date = new Date(date);
}
let date = TimeSince.getDateObj(this.props.date);

return (
<time
dateTime={date.toISOString()}
title={date.toString()}>{moment(date).fromNow(true)} {this.props.suffix || ''}</time>
title={date.toString()}>{this.state.relative} {this.props.suffix || ''}</time>
);
}
});
Expand Down