Skip to content

Timefilter API weirdness and inconsistencies #64125

@JacobBrandt

Description

@JacobBrandt

Kibana version:
6.6

Describe the bug:
The behavior of the API and it's values is not consistent.

On Discover page there is this method:

$scope.updateTime = function () {
  $scope.timeRange = {
    from: dateMath.parse(timefilter.getTime().from),
    to: dateMath.parse(timefilter.getTime().to, { roundUp: true })
  }
}

When 'This week' is selected on the Discover page as a time range the timefilter.getTime().from/to values are moment objects. Thus one would look at this method and say ok this is how I parse time filters for my own visualizations time ranges. However, on a dashboard when 'This week' is selected as a time range the from and to values are the same value and are NOT a moment object but a string "now/w". Thus the calculation doesn't work because from and to are the same value for some odd reason.

This kind of inconsistency is really disturbing. How is someone suppose to know that the same time range state does not return the same values from timefilter (in this case not even the same type of object for the value) depending on the page you are on.

The next issue is with the API. from/to are suppose to represent a range. However, on a dashboard they have the exact same value when the time selected is 'This week'. Thus the API itself is returning inconsistent values when it is in this state.

Time range state on a dashboard: This week
timefilter.getTime().from/to: Will both be now/w. Thus representing a single point in time
timefilter.getBounds().min/max : Will be two different moment objects whose range is a week

Expected behavior:
I would expect that the time range I select on pages would be represented in the timefilter values the same on all pages and not sometimes a string and sometimes a moment object for the exact same time range.

I also would expect know matter which part of the API is called to provide the same information.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions