+
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/server/__tests__/schema.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ describe('Schema', () => {
type RegularAccessHistogramForString {
histogram: [BucketsForNestedStringAgg]
}
type HistogramForBoolean {
histogram: [BucketsForNestedStringAgg]
}
type RegularAccessHistogramForBoolean {
histogram: [BucketsForNestedStringAgg]
}
type HistogramForNumber {
histogram(
rangeStart: Int,
Expand Down
19 changes: 18 additions & 1 deletion src/server/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const esgqlTypeMapping = {
byte: 'Int',
double: 'Float',
float: 'Float',
boolean: 'Boolean',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about just treat boolean as string for gql types?

either way, we will need to test before merging, especially to test use new Tube do ETL, and then see if Guppy/Portal can work (data explorer/study viewer)

One concern I have is that in data explorer we need to verify if we put a boolean field in filters, when selecting the filter, does it will send a string value back to guppy and causes problems. This can be testing in qa-covid19

Copy link
Contributor Author

@thanh-nguyen-dang thanh-nguyen-dang Apr 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is tested in qa-niaid @mfshao . And we should use boolean if graphql supports boolean.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't want see it tested in one env for one feature and after merging it breaks another feature in another env. If we know it might potential be dangerous, we need to do more testing and verify things are ok, or fix more before merging. Don't rush to merge into master

half_float: 'Float',
scaled_float: 'Float',
array: 'Object',
Expand Down Expand Up @@ -40,14 +41,17 @@ const getGQLType = (esInstance, esIndex, field, esFieldType) => {
const EnumAggsHistogramName = {
HISTOGRAM_FOR_STRING: 'HistogramForString',
HISTOGRAM_FOR_NUMBER: 'HistogramForNumber',
HISTOGRAM_FOR_BOOLEAN: 'HistogramForBoolean',
};
const gqlTypeToAggsHistogramName = {
String: EnumAggsHistogramName.HISTOGRAM_FOR_STRING,
Int: EnumAggsHistogramName.HISTOGRAM_FOR_NUMBER,
Float: EnumAggsHistogramName.HISTOGRAM_FOR_NUMBER,
Boolean: EnumAggsHistogramName.HISTOGRAM_FOR_BOOLEAN,
'[String]': EnumAggsHistogramName.HISTOGRAM_FOR_STRING,
'[Int]': EnumAggsHistogramName.HISTOGRAM_FOR_NUMBER,
'[Float]': EnumAggsHistogramName.HISTOGRAM_FOR_NUMBER,
'[Boolean]': EnumAggsHistogramName.HISTOGRAM_FOR_BOOLEAN,
};

const getAggsHistogramName = (gqlType) => {
Expand Down Expand Up @@ -244,6 +248,12 @@ const getTextHistogramSchema = (isRegularAccess) => `
}
`;

const getBooleanHistogramSchema = (isRegularAccess) => `
type ${(isRegularAccess ? histogramTypePrefix : '') + EnumAggsHistogramName.HISTOGRAM_FOR_BOOLEAN} {
histogram: [BucketsForNestedStringAgg]
}
`;

export const getMappingSchema = (esConfig) => `
type Mapping {
${esConfig.indices.map((cfg) => `${cfg.type} (
Expand All @@ -255,13 +265,20 @@ export const getMappingSchema = (esConfig) => `
export const getHistogramSchemas = () => {
const textHistogramSchema = getTextHistogramSchema(false);

const booleanHistogramSchema = getBooleanHistogramSchema(false);

const regularAccessTextHistogramSchema = getTextHistogramSchema(true);

const regularAccessBooleanHistogramSchema = getBooleanHistogramSchema(true);

const numberHistogramSchema = getNumberHistogramSchema(false);

const regularAccessNumberHistogramSchema = getNumberHistogramSchema(true);

const histogramSchemas = [textHistogramSchema, regularAccessTextHistogramSchema, numberHistogramSchema, regularAccessNumberHistogramSchema].join('\n');
const histogramSchemas = [
textHistogramSchema, regularAccessTextHistogramSchema, booleanHistogramSchema,
regularAccessBooleanHistogramSchema, numberHistogramSchema, regularAccessNumberHistogramSchema,
].join('\n');

return histogramSchemas;
};
Expand Down
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载