Revert :interval: work
Squashed commit of the following: commit 8b18f78098953c5aba744dd16a215b6ed4cd5143 Author: Luke Morris <lukevmorris@gmail.com> Date: Wed Feb 28 20:44:46 2018 -0800 Revert "Merge pull request #2663 from influxdata/feature/migrate-time-interval" This reverts commitpull/2903/head935186984c
, reversing changes made toe5b8889bc6
. commit 8f17059d24cc1a1bb4b8675be70fb9adb3f3a3e3 Author: Luke Morris <lukevmorris@gmail.com> Date: Wed Feb 28 20:44:23 2018 -0800 Revert "Merge pull request #2890 from influxdata/fix/time-interval" This reverts commitbb01a569ca
, reversing changes made to3609bc7d3a
.
parent
50da0a12d5
commit
4b54081cf8
|
@ -1,7 +1,6 @@
|
|||
package influx
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
@ -13,10 +12,6 @@ import (
|
|||
// SortTemplates the templates by size, then type, then value.
|
||||
func SortTemplates(ts []chronograf.TemplateVar) []chronograf.TemplateVar {
|
||||
sort.Slice(ts, func(i, j int) bool {
|
||||
if ts[i].Var == ":interval:" {
|
||||
return false
|
||||
}
|
||||
|
||||
if len(ts[i].Values) != len(ts[j].Values) {
|
||||
return len(ts[i].Values) < len(ts[j].Values)
|
||||
}
|
||||
|
@ -38,8 +33,6 @@ func SortTemplates(ts []chronograf.TemplateVar) []chronograf.TemplateVar {
|
|||
return ts
|
||||
}
|
||||
|
||||
var groupByRe = regexp.MustCompile("(?i)GROUP BY :interval:")
|
||||
|
||||
// RenderTemplate converts the template variable into a correct InfluxQL string based
|
||||
// on its type
|
||||
func RenderTemplate(query string, t chronograf.TemplateVar, now time.Time) (string, error) {
|
||||
|
@ -66,10 +59,16 @@ func RenderTemplate(query string, t chronograf.TemplateVar, now time.Time) (stri
|
|||
tv[t.Values[i].Type] = t.Values[i].Value
|
||||
}
|
||||
|
||||
query = groupByRe.ReplaceAllString(query, "GROUP BY time(:interval:)")
|
||||
|
||||
if pts, ok := tv["points"]; ok {
|
||||
points, err := strconv.ParseInt(pts, 0, 64)
|
||||
if res, ok := tv["resolution"]; ok {
|
||||
resolution, err := strconv.ParseInt(res, 0, 64)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
ppp, ok := tv["pointsPerPixel"]
|
||||
if !ok {
|
||||
ppp = "3"
|
||||
}
|
||||
pixelsPerPoint, err := strconv.ParseInt(ppp, 0, 64)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
@ -78,27 +77,28 @@ func RenderTemplate(query string, t chronograf.TemplateVar, now time.Time) (stri
|
|||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
interval := AutoInterval(points, dur)
|
||||
interval := AutoGroupBy(resolution, pixelsPerPoint, dur)
|
||||
return strings.Replace(query, t.Var, interval, -1), nil
|
||||
}
|
||||
|
||||
return query, nil
|
||||
}
|
||||
|
||||
func AutoInterval(points int64, duration time.Duration) string {
|
||||
// AutoGroupBy generates the time to group by in order to decimate the number of
|
||||
// points returned in a query
|
||||
func AutoGroupBy(resolution, pixelsPerPoint int64, duration time.Duration) string {
|
||||
// The function is: ((total_seconds * millisecond_converstion) / group_by) = pixels / 3
|
||||
// Number of points given the pixels
|
||||
pixels := float64(points)
|
||||
pixels := float64(resolution) / float64(pixelsPerPoint)
|
||||
msPerPixel := float64(duration/time.Millisecond) / pixels
|
||||
secPerPixel := float64(duration/time.Second) / pixels
|
||||
if secPerPixel < 1.0 {
|
||||
if msPerPixel < 1.0 {
|
||||
msPerPixel = 1.0
|
||||
}
|
||||
return strconv.FormatInt(int64(msPerPixel), 10) + "ms"
|
||||
return "time(" + strconv.FormatInt(int64(msPerPixel), 10) + "ms)"
|
||||
}
|
||||
// If groupby is more than 1 second round to the second
|
||||
return strconv.FormatInt(int64(secPerPixel), 10) + "s"
|
||||
return "time(" + strconv.FormatInt(int64(secPerPixel), 10) + "s)"
|
||||
}
|
||||
|
||||
// TemplateReplace replaces templates with values within the query string
|
||||
|
|
|
@ -125,38 +125,6 @@ func TestTemplateReplace(t *testing.T) {
|
|||
},
|
||||
want: `SELECT :field: FROM "cpu"`,
|
||||
},
|
||||
{
|
||||
name: "auto interval",
|
||||
query: `SELECT mean(usage_idle) from "cpu" where time > now() - 4320h group by time(:interval:)`,
|
||||
vars: []chronograf.TemplateVar{
|
||||
{
|
||||
Var: ":interval:",
|
||||
Values: []chronograf.TemplateValue{
|
||||
{
|
||||
Value: "333",
|
||||
Type: "points",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
want: `SELECT mean(usage_idle) from "cpu" where time > now() - 4320h group by time(46702s)`,
|
||||
},
|
||||
{
|
||||
name: "auto interval",
|
||||
query: `SELECT derivative(mean(usage_idle),:interval:) from "cpu" where time > now() - 4320h group by time(:interval:)`,
|
||||
vars: []chronograf.TemplateVar{
|
||||
{
|
||||
Var: ":interval:",
|
||||
Values: []chronograf.TemplateValue{
|
||||
{
|
||||
Value: "333",
|
||||
Type: "points",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
want: `SELECT derivative(mean(usage_idle),46702s) from "cpu" where time > now() - 4320h group by time(46702s)`,
|
||||
},
|
||||
{
|
||||
name: "auto group by",
|
||||
query: `SELECT mean(usage_idle) from "cpu" where time > now() - 4320h group by :interval:`,
|
||||
|
@ -165,13 +133,17 @@ func TestTemplateReplace(t *testing.T) {
|
|||
Var: ":interval:",
|
||||
Values: []chronograf.TemplateValue{
|
||||
{
|
||||
Value: "333",
|
||||
Type: "points",
|
||||
Value: "1000",
|
||||
Type: "resolution",
|
||||
},
|
||||
{
|
||||
Value: "3",
|
||||
Type: "pointsPerPixel",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
want: `SELECT mean(usage_idle) from "cpu" where time > now() - 4320h GROUP BY time(46702s)`,
|
||||
want: `SELECT mean(usage_idle) from "cpu" where time > now() - 4320h group by time(46655s)`,
|
||||
},
|
||||
{
|
||||
name: "auto group by without duration",
|
||||
|
@ -181,13 +153,17 @@ func TestTemplateReplace(t *testing.T) {
|
|||
Var: ":interval:",
|
||||
Values: []chronograf.TemplateValue{
|
||||
{
|
||||
Value: "333",
|
||||
Type: "points",
|
||||
Value: "1000",
|
||||
Type: "resolution",
|
||||
},
|
||||
{
|
||||
Value: "3",
|
||||
Type: "pointsPerPixel",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
want: `SELECT mean(usage_idle) from "cpu" WHERE time > now() - 4320h GROUP BY time(46702s)`,
|
||||
want: `SELECT mean(usage_idle) from "cpu" WHERE time > now() - 4320h group by time(46655s)`,
|
||||
},
|
||||
{
|
||||
name: "auto group by with :dashboardTime:",
|
||||
|
@ -197,8 +173,12 @@ func TestTemplateReplace(t *testing.T) {
|
|||
Var: ":interval:",
|
||||
Values: []chronograf.TemplateValue{
|
||||
{
|
||||
Value: "333",
|
||||
Type: "points",
|
||||
Value: "1000",
|
||||
Type: "resolution",
|
||||
},
|
||||
{
|
||||
Value: "3",
|
||||
Type: "pointsPerPixel",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -212,7 +192,7 @@ func TestTemplateReplace(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
want: `SELECT mean(usage_idle) from "cpu" WHERE time > now() - 4320h GROUP BY time(46702s)`,
|
||||
want: `SELECT mean(usage_idle) from "cpu" WHERE time > now() - 4320h group by time(46655s)`,
|
||||
},
|
||||
{
|
||||
name: "auto group by failing condition",
|
||||
|
@ -222,8 +202,12 @@ func TestTemplateReplace(t *testing.T) {
|
|||
Var: ":interval:",
|
||||
Values: []chronograf.TemplateValue{
|
||||
{
|
||||
Value: "38",
|
||||
Type: "points",
|
||||
Value: "115",
|
||||
Type: "resolution",
|
||||
},
|
||||
{
|
||||
Value: "3",
|
||||
Type: "pointsPerPixel",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -238,7 +222,7 @@ func TestTemplateReplace(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
want: `SELECT mean(usage_idle) FROM "cpu" WHERE time > now() - 1h GROUP BY time(94s)`,
|
||||
want: `SELECT mean(usage_idle) FROM "cpu" WHERE time > now() - 1h GROUP BY time(93s)`,
|
||||
},
|
||||
{
|
||||
name: "no template variables specified",
|
||||
|
@ -253,8 +237,12 @@ func TestTemplateReplace(t *testing.T) {
|
|||
Var: ":interval:",
|
||||
Values: []chronograf.TemplateValue{
|
||||
{
|
||||
Value: "38",
|
||||
Type: "points",
|
||||
Value: "115",
|
||||
Type: "resolution",
|
||||
},
|
||||
{
|
||||
Value: "3",
|
||||
Type: "pointsPerPixel",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -269,7 +257,7 @@ func TestTemplateReplace(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
want: `SELECT mean(usage_idle) FROM "cpu" WHERE time > now() - 1h GROUP BY time(94s)`,
|
||||
want: `SELECT mean(usage_idle) FROM "cpu" WHERE time > now() - 1h GROUP BY time(93s)`,
|
||||
},
|
||||
{
|
||||
name: "query with no template variables contained should return query",
|
||||
|
@ -280,7 +268,11 @@ func TestTemplateReplace(t *testing.T) {
|
|||
Values: []chronograf.TemplateValue{
|
||||
{
|
||||
Value: "115",
|
||||
Type: "points",
|
||||
Type: "resolution",
|
||||
},
|
||||
{
|
||||
Value: "3",
|
||||
Type: "pointsPerPixel",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -321,8 +313,12 @@ func Test_TemplateVarsUnmarshalling(t *testing.T) {
|
|||
"tempVar": ":interval:",
|
||||
"values": [
|
||||
{
|
||||
"value": "333",
|
||||
"type": "points"
|
||||
"value": "1000",
|
||||
"type": "resolution"
|
||||
},
|
||||
{
|
||||
"value": "3",
|
||||
"type": "pointsPerPixel"
|
||||
},
|
||||
{
|
||||
"value": "10",
|
||||
|
@ -347,8 +343,12 @@ func Test_TemplateVarsUnmarshalling(t *testing.T) {
|
|||
Var: ":interval:",
|
||||
Values: []chronograf.TemplateValue{
|
||||
{
|
||||
Value: "333",
|
||||
Type: "points",
|
||||
Value: "1000",
|
||||
Type: "resolution",
|
||||
},
|
||||
{
|
||||
Value: "3",
|
||||
Type: "pointsPerPixel",
|
||||
},
|
||||
{
|
||||
Value: "10",
|
||||
|
@ -379,6 +379,46 @@ func Test_TemplateVarsUnmarshalling(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestAutoGroupBy(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
resolution int64
|
||||
pixelsPerPoint int64
|
||||
duration time.Duration
|
||||
want string
|
||||
}{
|
||||
{
|
||||
name: "String() calculates the GROUP BY interval",
|
||||
resolution: 700,
|
||||
pixelsPerPoint: 3,
|
||||
duration: 24 * time.Hour,
|
||||
want: "time(370s)",
|
||||
},
|
||||
{
|
||||
name: "String() milliseconds if less than one second intervals",
|
||||
resolution: 100000,
|
||||
pixelsPerPoint: 3,
|
||||
duration: time.Hour,
|
||||
want: "time(107ms)",
|
||||
},
|
||||
{
|
||||
name: "String() milliseconds if less than one millisecond",
|
||||
resolution: 100000,
|
||||
pixelsPerPoint: 3,
|
||||
duration: time.Second,
|
||||
want: "time(1ms)",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
got := AutoGroupBy(tt.resolution, tt.pixelsPerPoint, tt.duration)
|
||||
if got != tt.want {
|
||||
t.Errorf("TestAutoGroupBy %s =\n%s\nwant\n%s", tt.name, got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func Test_RenderTemplate(t *testing.T) {
|
||||
gbvTests := []struct {
|
||||
name string
|
||||
|
@ -389,37 +429,37 @@ func Test_RenderTemplate(t *testing.T) {
|
|||
{
|
||||
name: "relative time only lower bound with one day of duration",
|
||||
query: "SELECT mean(usage_idle) FROM cpu WHERE time > now() - 1d GROUP BY :interval:",
|
||||
resolution: 333,
|
||||
resolution: 1000,
|
||||
want: "SELECT mean(usage_idle) FROM cpu WHERE time > now() - 1d GROUP BY time(259s)",
|
||||
},
|
||||
{
|
||||
name: "relative time offset by week",
|
||||
query: "SELECT mean(usage_idle) FROM cpu WHERE time > now() - 1d - 7d AND time < now() - 7d GROUP BY :interval:",
|
||||
resolution: 333,
|
||||
resolution: 1000,
|
||||
want: "SELECT mean(usage_idle) FROM cpu WHERE time > now() - 1d - 7d AND time < now() - 7d GROUP BY time(259s)",
|
||||
},
|
||||
{
|
||||
name: "relative time with relative upper bound with one minute of duration",
|
||||
query: "SELECT mean(usage_idle) FROM cpu WHERE time > now() - 3m AND time < now() - 2m GROUP BY :interval:",
|
||||
resolution: 333,
|
||||
want: "SELECT mean(usage_idle) FROM cpu WHERE time > now() - 3m AND time < now() - 2m GROUP BY time(180ms)",
|
||||
resolution: 1000,
|
||||
want: "SELECT mean(usage_idle) FROM cpu WHERE time > now() - 3m AND time < now() - 2m GROUP BY time(179ms)",
|
||||
},
|
||||
{
|
||||
name: "relative time with relative lower bound and now upper with one day of duration",
|
||||
query: "SELECT mean(usage_idle) FROM cpu WHERE time > now() - 1d AND time < now() GROUP BY :interval:",
|
||||
resolution: 333,
|
||||
resolution: 1000,
|
||||
want: "SELECT mean(usage_idle) FROM cpu WHERE time > now() - 1d AND time < now() GROUP BY time(259s)",
|
||||
},
|
||||
{
|
||||
name: "absolute time with one minute of duration",
|
||||
query: "SELECT mean(usage_idle) FROM cpu WHERE time > '1985-10-25T00:01:00Z' and time < '1985-10-25T00:02:00Z' GROUP BY :interval:",
|
||||
resolution: 333,
|
||||
want: "SELECT mean(usage_idle) FROM cpu WHERE time > '1985-10-25T00:01:00Z' and time < '1985-10-25T00:02:00Z' GROUP BY time(180ms)",
|
||||
resolution: 1000,
|
||||
want: "SELECT mean(usage_idle) FROM cpu WHERE time > '1985-10-25T00:01:00Z' and time < '1985-10-25T00:02:00Z' GROUP BY time(179ms)",
|
||||
},
|
||||
{
|
||||
name: "absolute time with nano seconds and zero duration",
|
||||
query: "SELECT mean(usage_idle) FROM cpu WHERE time > '2017-07-24T15:33:42.994Z' and time < '2017-07-24T15:33:42.994Z' GROUP BY :interval:",
|
||||
resolution: 333,
|
||||
resolution: 1000,
|
||||
want: "SELECT mean(usage_idle) FROM cpu WHERE time > '2017-07-24T15:33:42.994Z' and time < '2017-07-24T15:33:42.994Z' GROUP BY time(1ms)",
|
||||
},
|
||||
{
|
||||
|
@ -440,7 +480,7 @@ func Test_RenderTemplate(t *testing.T) {
|
|||
Values: []chronograf.TemplateValue{
|
||||
{
|
||||
Value: fmt.Sprintf("%d", tt.resolution),
|
||||
Type: "points",
|
||||
Type: "resolution",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
@ -155,14 +155,18 @@ func TestService_Queries(t *testing.T) {
|
|||
"tempVar": ":interval:",
|
||||
"values": [
|
||||
{
|
||||
"value": "333",
|
||||
"type": "points"
|
||||
"value": "1000",
|
||||
"type": "resolution"
|
||||
},
|
||||
{
|
||||
"value": "3",
|
||||
"type": "pointsPerPixel"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}`))),
|
||||
want: `{"queries":[{"id":"82b60d37-251e-4afe-ac93-ca20a3642b11","query":"SELECT \"pingReq\" FROM :dbs:.\"monitor\".\"httpd\" WHERE time \u003e :dashboardTime: AND time \u003c :upperDashboardTime: GROUP BY :interval:","queryConfig":{"id":"82b60d37-251e-4afe-ac93-ca20a3642b11","database":"","measurement":"","retentionPolicy":"","fields":[],"tags":{},"groupBy":{"time":"","tags":[]},"areTagsAccepted":false,"rawText":"SELECT \"pingReq\" FROM :dbs:.\"monitor\".\"httpd\" WHERE time \u003e :dashboardTime: AND time \u003c :upperDashboardTime: GROUP BY :interval:","range":null,"shifts":[]},"queryTemplated":"SELECT \"pingReq\" FROM \"_internal\".\"monitor\".\"httpd\" WHERE time \u003e now() - 15m AND time \u003c now() GROUP BY time(2s)","tempVars":[{"tempVar":":upperDashboardTime:","values":[{"value":"now()","type":"constant","selected":true}]},{"tempVar":":dashboardTime:","values":[{"value":"now() - 15m","type":"constant","selected":true}]},{"tempVar":":dbs:","values":[{"value":"_internal","type":"database","selected":true}]},{"tempVar":":interval:","values":[{"value":"333","type":"points","selected":false}]}]}]}
|
||||
want: `{"queries":[{"id":"82b60d37-251e-4afe-ac93-ca20a3642b11","query":"SELECT \"pingReq\" FROM :dbs:.\"monitor\".\"httpd\" WHERE time \u003e :dashboardTime: AND time \u003c :upperDashboardTime: GROUP BY :interval:","queryConfig":{"id":"82b60d37-251e-4afe-ac93-ca20a3642b11","database":"","measurement":"","retentionPolicy":"","fields":[],"tags":{},"groupBy":{"time":"","tags":[]},"areTagsAccepted":false,"rawText":"SELECT \"pingReq\" FROM :dbs:.\"monitor\".\"httpd\" WHERE time \u003e :dashboardTime: AND time \u003c :upperDashboardTime: GROUP BY :interval:","range":null,"shifts":[]},"queryTemplated":"SELECT \"pingReq\" FROM \"_internal\".\"monitor\".\"httpd\" WHERE time \u003e now() - 15m AND time \u003c now() GROUP BY time(2s)","tempVars":[{"tempVar":":upperDashboardTime:","values":[{"value":"now()","type":"constant","selected":true}]},{"tempVar":":dashboardTime:","values":[{"value":"now() - 15m","type":"constant","selected":true}]},{"tempVar":":dbs:","values":[{"value":"_internal","type":"database","selected":true}]},{"tempVar":":interval:","values":[{"value":"1000","type":"resolution","selected":false},{"value":"3","type":"pointsPerPixel","selected":false}]}]}]}
|
||||
`,
|
||||
},
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ import {
|
|||
templateControlBarVisibilityToggled as templateControlBarVisibilityToggledAction,
|
||||
} from 'shared/actions/app'
|
||||
import {presentationButtonDispatcher} from 'shared/dispatchers'
|
||||
import {interval, DASHBOARD_LAYOUT_ROW_HEIGHT} from 'shared/constants'
|
||||
import {DASHBOARD_LAYOUT_ROW_HEIGHT} from 'shared/constants'
|
||||
|
||||
const FORMAT_INFLUXQL = 'influxql'
|
||||
const defaultTimeRange = {
|
||||
|
@ -336,6 +336,25 @@ class DashboardPage extends Component {
|
|||
],
|
||||
}
|
||||
|
||||
const interval = {
|
||||
id: 'interval',
|
||||
type: 'autoGroupBy',
|
||||
tempVar: ':interval:',
|
||||
label: 'automatically determine the best group by time',
|
||||
values: [
|
||||
{
|
||||
value: '1000', // pixels
|
||||
type: 'resolution',
|
||||
selected: true,
|
||||
},
|
||||
{
|
||||
value: '3',
|
||||
type: 'pointsPerPixel',
|
||||
selected: true,
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
let templatesIncludingDashTime
|
||||
if (dashboard) {
|
||||
templatesIncludingDashTime = [
|
||||
|
|
|
@ -7,7 +7,7 @@ import {Table, Column, Cell} from 'fixed-data-table'
|
|||
import Dropdown from 'shared/components/Dropdown'
|
||||
import CustomCell from 'src/data_explorer/components/CustomCell'
|
||||
import TabItem from 'src/data_explorer/components/TableTabItem'
|
||||
import {TEMPLATES} from 'src/shared/constants'
|
||||
import {TEMPLATES} from 'src/data_explorer/constants'
|
||||
|
||||
import {fetchTimeSeriesAsync} from 'shared/actions/timeSeries'
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import _ from 'lodash'
|
|||
import {fetchTimeSeriesAsync} from 'shared/actions/timeSeries'
|
||||
import {resultsToCSV} from 'src/shared/parsing/resultsToCSV.js'
|
||||
import download from 'src/external/download.js'
|
||||
import {TEMPLATES} from 'src/shared/constants'
|
||||
import {TEMPLATES} from 'src/data_explorer/constants'
|
||||
|
||||
const getCSV = (query, errorThrown) => async () => {
|
||||
try {
|
||||
|
|
|
@ -81,3 +81,16 @@ export const QUERY_TEMPLATES = [
|
|||
{text: 'Show Stats', query: 'SHOW STATS'},
|
||||
{text: 'Show Diagnostics', query: 'SHOW DIAGNOSTICS'},
|
||||
]
|
||||
|
||||
const interval = {
|
||||
id: 'interval',
|
||||
type: 'autoGroupBy',
|
||||
tempVar: ':interval:',
|
||||
label: 'automatically determine the best group by time',
|
||||
values: [
|
||||
{value: '1000', type: 'resolution', selected: true},
|
||||
{value: '3', type: 'pointsPerPixel', selected: true},
|
||||
],
|
||||
} // pixels
|
||||
|
||||
export const TEMPLATES = [interval]
|
||||
|
|
|
@ -6,16 +6,16 @@ import queryString from 'query-string'
|
|||
|
||||
import _ from 'lodash'
|
||||
|
||||
import QueryMaker from 'src/data_explorer/components/QueryMaker'
|
||||
import Visualization from 'src/data_explorer/components/Visualization'
|
||||
import QueryMaker from '../components/QueryMaker'
|
||||
import Visualization from '../components/Visualization'
|
||||
import WriteDataForm from 'src/data_explorer/components/WriteDataForm'
|
||||
import Header from 'src/data_explorer/containers/Header'
|
||||
import ResizeContainer from 'src/shared/components/ResizeContainer'
|
||||
import OverlayTechnologies from 'src/shared/components/OverlayTechnologies'
|
||||
import Header from '../containers/Header'
|
||||
import ResizeContainer from 'shared/components/ResizeContainer'
|
||||
import OverlayTechnologies from 'shared/components/OverlayTechnologies'
|
||||
import ManualRefresh from 'src/shared/components/ManualRefresh'
|
||||
|
||||
import {VIS_VIEWS, AUTO_GROUP_BY, TEMPLATES} from 'src/shared/constants'
|
||||
import {MINIMUM_HEIGHTS, INITIAL_HEIGHTS} from 'src/data_explorer/constants'
|
||||
import {VIS_VIEWS, AUTO_GROUP_BY} from 'shared/constants'
|
||||
import {MINIMUM_HEIGHTS, INITIAL_HEIGHTS, TEMPLATES} from '../constants'
|
||||
import {errorThrown} from 'shared/actions/errors'
|
||||
import {setAutoRefresh} from 'shared/actions/app'
|
||||
import * as dataExplorerActionCreators from 'src/data_explorer/actions/view'
|
||||
|
|
|
@ -3,7 +3,6 @@ import _ from 'lodash'
|
|||
|
||||
import {fetchTimeSeriesAsync} from 'shared/actions/timeSeries'
|
||||
import {removeUnselectedTemplateValues} from 'src/dashboards/constants'
|
||||
import {intervalValuesPoints} from 'src/shared/constants'
|
||||
|
||||
const AutoRefresh = ComposedComponent => {
|
||||
class wrapper extends Component {
|
||||
|
@ -97,38 +96,31 @@ const AutoRefresh = ComposedComponent => {
|
|||
const timeSeriesPromises = queries.map(query => {
|
||||
const {host, database, rp} = query
|
||||
|
||||
const templatesWithIntervalVals = templates.map(temp => {
|
||||
const templatesWithResolution = templates.map(temp => {
|
||||
if (temp.tempVar === ':interval:') {
|
||||
if (resolution) {
|
||||
// resize event
|
||||
return {
|
||||
...temp,
|
||||
values: temp.values.map(v => {
|
||||
if (v.type === 'resolution') {
|
||||
return {...v, value: `${resolution}`}
|
||||
}
|
||||
if (v.type === 'points') {
|
||||
return {
|
||||
...v,
|
||||
value: `${_.toInteger(Number(resolution) / 3)}`,
|
||||
}
|
||||
}
|
||||
return v
|
||||
}),
|
||||
values: temp.values.map(
|
||||
v => (temp.type === 'resolution' ? {...v, resolution} : v)
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
...temp,
|
||||
values: intervalValuesPoints,
|
||||
values: [
|
||||
...temp.values,
|
||||
{value: '1000', type: 'resolution', selected: true},
|
||||
],
|
||||
}
|
||||
}
|
||||
|
||||
return temp
|
||||
})
|
||||
|
||||
const tempVars = removeUnselectedTemplateValues(
|
||||
templatesWithIntervalVals
|
||||
)
|
||||
const tempVars = removeUnselectedTemplateValues(templatesWithResolution)
|
||||
|
||||
return fetchTimeSeriesAsync(
|
||||
{
|
||||
source: host,
|
||||
|
|
|
@ -430,20 +430,6 @@ export const DEFAULT_SOURCE = {
|
|||
metaUrl: '',
|
||||
}
|
||||
|
||||
export const intervalValuesPoints = [
|
||||
{value: '333', type: 'points', selected: true},
|
||||
]
|
||||
|
||||
export const interval = {
|
||||
id: 'interval',
|
||||
type: 'autoGroupBy',
|
||||
tempVar: ':interval:',
|
||||
label: 'automatically determine the best group by time',
|
||||
values: intervalValuesPoints,
|
||||
}
|
||||
|
||||
export const TEMPLATES = [interval]
|
||||
|
||||
export const IS_STATIC_LEGEND = legend =>
|
||||
_.get(legend, 'type', false) === 'static'
|
||||
|
||||
|
|
|
@ -157,9 +157,9 @@ function _buildGroupByTime(groupBy) {
|
|||
return ''
|
||||
}
|
||||
|
||||
return ` GROUP BY time(${groupBy.time === AUTO_GROUP_BY
|
||||
return ` GROUP BY ${groupBy.time === AUTO_GROUP_BY
|
||||
? TEMP_VAR_INTERVAL
|
||||
: `${groupBy.time}`})`
|
||||
: `time(${groupBy.time})`}`
|
||||
}
|
||||
|
||||
function _buildGroupByTags(groupBy) {
|
||||
|
|
Loading…
Reference in New Issue