WIP
parent
ef4b01513b
commit
42d508e35a
|
@ -144,9 +144,9 @@ describe('Chronograf.Reducers.DataExplorer.queryConfigs', () => {
|
|||
const oneFieldOneFunc = reducer(
|
||||
state,
|
||||
applyFuncsToField(queryId, {
|
||||
name: 'mean',
|
||||
alias: `mean_usage_user`,
|
||||
args: ['usage_user'],
|
||||
name: 'func1',
|
||||
alias: 'func1_field1',
|
||||
args: ['field1'],
|
||||
type: 'func',
|
||||
})
|
||||
)
|
||||
|
@ -154,18 +154,17 @@ describe('Chronograf.Reducers.DataExplorer.queryConfigs', () => {
|
|||
const newState = reducer(
|
||||
oneFieldOneFunc,
|
||||
toggleField(queryId, {
|
||||
name: 'f1',
|
||||
name: 'f2',
|
||||
alias: null,
|
||||
args: [],
|
||||
type: 'field',
|
||||
})
|
||||
)
|
||||
|
||||
expect(newState[queryId].fields[1].name).to.equal('mean')
|
||||
expect(newState[queryId].fields[1].alias).to.equal('mean_f1')
|
||||
expect(newState[queryId].fields[1].args).to.deep.equal(['f1'])
|
||||
expect(newState[queryId].fields[1].name).to.equal('func1')
|
||||
expect(newState[queryId].fields[1].alias).to.equal('func1_f2')
|
||||
expect(newState[queryId].fields[1].args).to.deep.equal(['f2'])
|
||||
expect(newState[queryId].fields[1].type).to.equal('func')
|
||||
expect(newState[queryId].fields[1].type).to.equal('field')
|
||||
})
|
||||
|
||||
it('adds the field property to query config if not found', () => {
|
||||
|
|
|
@ -23,13 +23,19 @@ export const chooseMeasurement = (
|
|||
measurement,
|
||||
})
|
||||
|
||||
export const toggleField = (query, {field, funcs}, isKapacitorRule = false) => {
|
||||
export const toggleField = (
|
||||
query,
|
||||
{name, alias, args, type},
|
||||
isKapacitorRule = false
|
||||
) => {
|
||||
const {fields, groupBy} = query
|
||||
|
||||
if (!fields) {
|
||||
if (!fields && !fields.length) {
|
||||
return {
|
||||
...query,
|
||||
fields: [{field, funcs: ['mean']}],
|
||||
fields: [
|
||||
{type: 'func', alias: `mean_${name}`, args: [name], name: 'mean'},
|
||||
],
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue