Skip to content

Commit

Permalink
[Fix][Infrastructure UI] Incorrect payload in time range when landing…
Browse files Browse the repository at this point in the history
… on the Hosts View (#147390)

Closes #146581 

## Summary

This PR fixes the initial `from` date range calculation. The idea is to
convert first the initial range of minutes to milliseconds. Then in
order to get the date of `CALCULATED_DATE_RANGE_TO` - (the calculated
initial range in milliseconds) and call `getTime()` to receive the
calculated `from` date as timestamp.

To test that you can open the host page without the time range in the
URL. Then check the `from` value as in the screenshot attached to the
story and you can use an [Unix timestamp
converter](https://www.unixtimestamp.com/) to verify that the
calculation is correct
  • Loading branch information
jennypavlova authored Dec 13, 2022
1 parent 274ed54 commit 29841da
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ const DEFAULT_QUERY = {
const DEFAULT_FROM_MINUTES_VALUE = 15;
const INITIAL_DATE = new Date();
export const INITIAL_DATE_RANGE = { from: `now-${DEFAULT_FROM_MINUTES_VALUE}m`, to: 'now' };
const CALCULATED_DATE_RANGE_TO = INITIAL_DATE.getTime();
const DEFAULT_FROM_IN_MILLISECONDS = DEFAULT_FROM_MINUTES_VALUE * 60000;
const CALCULATED_DATE_RANGE_FROM = new Date(
INITIAL_DATE.getMinutes() - DEFAULT_FROM_MINUTES_VALUE
CALCULATED_DATE_RANGE_TO - DEFAULT_FROM_IN_MILLISECONDS
).getTime();
const CALCULATED_DATE_RANGE_TO = INITIAL_DATE.getTime();

const INITIAL_HOSTS_STATE: HostsState = {
query: DEFAULT_QUERY,
Expand Down

0 comments on commit 29841da

Please sign in to comment.