diff --git a/frontend/src/metabase/lib/data-modeling/metadata.ts b/frontend/src/metabase/lib/data-modeling/metadata.ts index d118192e39becb50289a7f2b5b8fbbd7d9f70a02..2773487ce9a973852a7f40cc147463574fbe5d3f 100644 --- a/frontend/src/metabase/lib/data-modeling/metadata.ts +++ b/frontend/src/metabase/lib/data-modeling/metadata.ts @@ -1,6 +1,7 @@ export type FieldMetadata = { id?: number; name: string; + display_name: string; description?: string | null; semantic_type?: string | null; }; @@ -23,13 +24,13 @@ const MAX_FIELD_SCORE = 3; * @returns {number} — int between 0 and 3 */ function getFieldMetadataScore({ - name, + display_name, description, semantic_type, }: FieldMetadata): number { let score = 0; - const isNameDirty = name.includes("→") || name.includes("_"); + const isNameDirty = display_name.includes("→") || display_name.includes("_"); if (!isNameDirty) { score++; diff --git a/frontend/src/metabase/lib/data-modeling/metadata.unit.spec.js b/frontend/src/metabase/lib/data-modeling/metadata.unit.spec.js index a0020b047f94779d9ee557cd87611b5933b42fb0..c627c84ce223c6b112f32b2d07708378a3e85b96 100644 --- a/frontend/src/metabase/lib/data-modeling/metadata.unit.spec.js +++ b/frontend/src/metabase/lib/data-modeling/metadata.unit.spec.js @@ -7,8 +7,8 @@ describe("getDatasetMetadataCompletenessPercentage", () => { it("returns 0 for completely missing metadata", () => { const percent = getDatasetMetadataCompletenessPercentage([ - { name: "Created_At" }, - { name: "Products → Category" }, + { display_name: "Created_At" }, + { display_name: "Products → Category" }, ]); expect(percent).toBe(0); }); @@ -16,12 +16,12 @@ describe("getDatasetMetadataCompletenessPercentage", () => { it("returns 1 for complete metadata", () => { const percent = getDatasetMetadataCompletenessPercentage([ { - name: "Created At", + display_name: "Created At", description: "Date created", semantic_type: "DateTime", }, { - name: "Product Category", + display_name: "Product Category", description: "The name is pretty self-explaining", semantic_type: "String", }, @@ -31,9 +31,9 @@ describe("getDatasetMetadataCompletenessPercentage", () => { it("returns 0.5 for half-complete metadata", () => { const percent = getDatasetMetadataCompletenessPercentage([ - { name: "Created_At" }, + { display_name: "Created_At" }, { - name: "Product Category", + display_name: "Product Category", description: "The name is pretty self-explaining", semantic_type: "String", }, @@ -43,9 +43,9 @@ describe("getDatasetMetadataCompletenessPercentage", () => { it("returns percent value for partially complete metadata", () => { const percent = getDatasetMetadataCompletenessPercentage([ - { name: "Created_At" }, + { display_name: "Created_At" }, { - name: "Product Category", + display_name: "Product Category", semantic_type: "String", }, ]); diff --git a/frontend/src/metabase/query_builder/components/view/sidebars/DatasetManagementSection/DatasetMetadataStrengthIndicator/DatasetMetadataStrengthIndicator.unit.spec.js b/frontend/src/metabase/query_builder/components/view/sidebars/DatasetManagementSection/DatasetMetadataStrengthIndicator/DatasetMetadataStrengthIndicator.unit.spec.js index c03d92f64d2ebc3f7b02e4e64f94dbb7e387261d..7525a377f5f2c86f149ccf52f4f5bfcbad256197 100644 --- a/frontend/src/metabase/query_builder/components/view/sidebars/DatasetManagementSection/DatasetMetadataStrengthIndicator/DatasetMetadataStrengthIndicator.unit.spec.js +++ b/frontend/src/metabase/query_builder/components/view/sidebars/DatasetManagementSection/DatasetMetadataStrengthIndicator/DatasetMetadataStrengthIndicator.unit.spec.js @@ -17,16 +17,16 @@ function setup({ resultMetadata } = {}) { describe("DatasetMetadataStrengthIndicator", () => { const FULLY_COMPLETE_METADATA = { id: 1, - name: "ID", + display_name: "ID", description: "Well, that's an ID", semantic_type: "type/PK", }; const PARTIALLY_COMPLETE_METADATA = { id: 1, - name: "ID", + display_name: "ID", semantic_type: "type/PK", }; - const FULLY_INCOMPLETE_METADATA = { name: "CREATED_AT" }; + const FULLY_INCOMPLETE_METADATA = { display_name: "CREATED_AT" }; it("doesn't render if result metadata is not defined", () => { setup({ resultMetadata: undefined });