fix(schema-explorer): update the flux schema explorer to use v1 package (#5323)

Closes https://github.com/influxdata/chronograf/issues/5316
pull/5326/head
Michael Desa 2019-11-22 09:01:43 -05:00 committed by GitHub
parent 46f8d51980
commit adef73900c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 32 deletions

View File

@ -1,3 +1,11 @@
## v1.7.16
### Bug Fixes
1. [#5265](https://github.com/influxdata/chronograf/pull/5323): fix(schema-explorer): update the flux schema explorer to use v1 package
### Features
## v1.7.15
### Features

View File

@ -8,11 +8,8 @@ export const measurements = async (
bucket: string
): Promise<any> => {
const script = `
from(bucket:"${bucket}")
|> range(start:-30d)
|> group(columns:["_measurement"], mode: "by")
|> distinct(column:"_measurement")
|> group()
import "influxdata/influxdb/v1"
v1.measurements(bucket:"${bucket}")
`
return proxy(source, script)
@ -62,16 +59,16 @@ export const tagKeys = async (
tagKeyFilter = `|> filter(fn: (r) => ${predicates.join(' and ')} )`
}
const predicate = '(r) => true'
const script = `
from(bucket: "${bucket}")
|> range(start: -30d)
${tagsetFilter(filter)}
|> keys()
|> keep(columns: ["_value"])
|> group()
|> distinct()
|> map(fn: (r) => r._value)
${tagKeyFilter}
import "influxdata/influxdb/v1"
v1.tagKeys(
bucket: "${bucket}",
predicate: ${predicate},
start: -30d,
)
${tagKeyFilter}
`
return proxy(source, script)
@ -103,15 +100,19 @@ export const tagValues = async ({
const limitFunc = count ? '' : `|> limit(n:${limit})`
const countFunc = count ? '|> count()' : ''
const predicate = '(r) => true'
const script = `
from(bucket:"${bucket}")
|> range(start:-30d)
${regexFilter}
|> group(columns:["${tagKey}"], mode: "by")
|> distinct(column:"${tagKey}")
|> group(columns:["_stop","_start"], mode: "by")
${limitFunc}
${countFunc}
import "influxdata/influxdb/v1"
v1.tagValues(
bucket: "${bucket}",
predicate: ${predicate},
tag: "${tagKey}",
start: -30d,
)
${regexFilter}
${limitFunc}
${countFunc}
`
return proxy(source, script)
@ -134,16 +135,6 @@ export const tagsFromMeasurement = async (
return proxy(source, script)
}
const tagsetFilter = (filter: SchemaFilter[]): string => {
if (!filter.length) {
return ''
}
const predicates = filter.map(({key, value}) => `r.${key} == "${value}"`)
return `|> filter(fn: (r) => ${predicates.join(' and ')} )`
}
export const proxy = async (source: Source, script: string) => {
const mark = encodeURIComponent('?')
const garbage = script.replace(/\s/g, '') // server cannot handle whitespace