Skip to content

Commit 1467f26

Browse files
committed
remove created_time and last_updated_time from aggregation query
1 parent bee0177 commit 1467f26

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

modules/components/src/Aggs/AggsQuery.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { capitalize } from 'lodash';
33
import Query from '../Query';
44
import defaultApi from '../utils/api';
55
import { queryFromAgg } from './AggsState';
6+
import { excludeQueryFields } from './AggsState';
67

78
export default ({ index = '', aggs = [], sqon = null, api = defaultApi, ...props }) => {
89
return !index || !aggs.length ? (
@@ -27,7 +28,13 @@ export default ({ index = '', aggs = [], sqon = null, api = defaultApi, ...props
2728
aggregations_filter_themselves: false
2829
filters: $sqon
2930
){
30-
${aggs.map((x) => x.query || queryFromAgg(x))}
31+
${aggs.map(
32+
(x) =>
33+
x.query ||
34+
(!excludeQueryFields.some((excludedField) => excludedField === x.field)
35+
? queryFromAgg(x)
36+
: x.query),
37+
)}
3138
}
3239
}
3340
}

modules/components/src/Aggs/AggsState.js

+13-5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ let aggFields = `
1212
}
1313
`;
1414

15+
export const excludeQueryFields = ['created_time', 'last_updated_time'];
16+
1517
export const queryFromAgg = ({ field, type }) =>
1618
type === 'Aggregations'
1719
? `
@@ -138,15 +140,21 @@ export default class extends Component {
138140
update: this.update,
139141
aggs: this.state.temp.map((x) => {
140142
const type = getMappingTypeOfField({ field: x.field, mapping }) || x.type;
141-
return {
143+
const agg = {
142144
...x,
143145
type,
144-
query: queryFromAgg({
145-
...x,
146-
type,
147-
}),
148146
isTerms: type === 'Aggregations',
147+
...(!excludeQueryFields.some((excludeField) => excludeField === x.field)
148+
? {
149+
query: queryFromAgg({
150+
...x,
151+
type,
152+
}),
153+
}
154+
: {}),
149155
};
156+
157+
return agg;
150158
}),
151159
saveOrder: this.saveOrder,
152160
loading: this.state.loading,

modules/components/src/App.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const App = () => {
4848
disableSocket
4949
graphqlField="devalias" // static
5050
projectId="dev" // static
51-
projectCode="indoctestproject" // dynamic
51+
projectCode="bd2siteproject" // dynamic
5252
render={(props) => {
5353
return (
5454
<>

0 commit comments

Comments
 (0)