From d7f5220e0aabad9fcca320733644e0d956090d78 Mon Sep 17 00:00:00 2001 From: Doug Beatty Date: Thu, 9 Feb 2023 20:41:04 -0700 Subject: [PATCH 1/4] Enable searching column descriptions --- src/app/components/search/search.html | 2 ++ src/app/components/search/search.js | 8 +++++--- src/app/services/project_service.js | 14 +++++++++++++- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/app/components/search/search.html b/src/app/components/search/search.html index 4acfaea2..d6995c41 100644 --- a/src/app/components/search/search.html +++ b/src/app/components/search/search.html @@ -22,6 +22,8 @@

+ + diff --git a/src/app/components/search/search.js b/src/app/components/search/search.js index 8d745f0f..8c5ed24c 100644 --- a/src/app/components/search/search.js +++ b/src/app/components/search/search.js @@ -28,6 +28,7 @@ angular show_names : false, show_descriptions: false, show_columns: false, + show_column_descriptions: false, show_code: false, show_tags: false }; @@ -62,17 +63,18 @@ angular let finalResults = []; let fileIDs = []; - const {show_names, show_descriptions, show_columns, show_code, show_tags} = checkboxStatus; + const {show_names, show_descriptions, show_columns, show_column_descriptions, show_code, show_tags} = checkboxStatus; _.each(results, function(result){ _.each(result.matches, function(match){ if(!fileIDs.includes(result.model['unique_id'])){ const nameMatch = show_names && (match.key === "name" || match.key == 'label'); const descriptionMatch = show_descriptions && match.key == "description"; const columnsMatch = show_columns && match.key === "columns"; + const columnDescriptionMatch = show_column_descriptions && match.key === "column_description"; const codeMatch = show_code && match.key === "raw_code"; const tagsMatch = show_tags && match.key === "tags"; - if(nameMatch || descriptionMatch || columnsMatch || codeMatch || tagsMatch) { + if(nameMatch || descriptionMatch || columnsMatch || columnDescriptionMatch || codeMatch || tagsMatch) { fileIDs.push(result.model['unique_id']); finalResults.push(result); } @@ -82,7 +84,7 @@ angular return finalResults; } - var watchExpressions = ['query', 'checkboxStatus.show_names', 'checkboxStatus.show_descriptions', 'checkboxStatus.show_columns', 'checkboxStatus.show_code', 'checkboxStatus.show_tags']; + var watchExpressions = ['query', 'checkboxStatus.show_names', 'checkboxStatus.show_descriptions', 'checkboxStatus.show_columns', 'checkboxStatus.show_column_descriptions', 'checkboxStatus.show_code', 'checkboxStatus.show_tags']; scope.$watchGroup(watchExpressions, function() { scope.results = filterResults(projectService.search(scope.query), scope.checkboxStatus); }); diff --git a/src/app/services/project_service.js b/src/app/services/project_service.js index 121c2fdb..1c351b7b 100644 --- a/src/app/services/project_service.js +++ b/src/app/services/project_service.js @@ -266,6 +266,7 @@ angular 'description':'string', 'raw_code':'string', 'columns':'object', + 'column_description':'n/a', // special case 'tags': 'array', 'arguments': 'array', 'label': 'string', @@ -274,7 +275,18 @@ angular let query_segments = _.words(query.toLowerCase()); for (var i in search_keys) { - if (!obj[i]) { + + // column descriptions are a special case because they are not a top-level key + if (i === 'column_description') { + for (var column_name in obj["columns"]) { + if (obj["columns"][column_name]["description"] != null) { + if (query_segments.every(segment => obj["columns"][column_name]["description"].toLowerCase().indexOf(segment) != -1)) { + objects.push({key: i, value: query}); + } + } + } + } else if (!obj[i]) { + // skip any other cases where the object is missing the key continue; } else if (search_keys[i] === 'string' && query_segments.every(segment => obj[i].toLowerCase().indexOf(segment) != -1)) { objects.push({key: i, value: query}); From 354a2b26d2d209ba0c76be652968947c6028d9c7 Mon Sep 17 00:00:00 2001 From: Doug Beatty Date: Thu, 9 Feb 2023 20:42:39 -0700 Subject: [PATCH 2/4] Give the tag checkbox a unique id --- src/app/components/search/search.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/components/search/search.html b/src/app/components/search/search.html index d6995c41..dbdf54be 100644 --- a/src/app/components/search/search.html +++ b/src/app/components/search/search.html @@ -26,7 +26,7 @@

- + From bbc0f243769c310d48eed4c541b4d2618afedf93 Mon Sep 17 00:00:00 2001 From: Doug Beatty Date: Thu, 9 Feb 2023 20:44:48 -0700 Subject: [PATCH 3/4] Fix typos --- src/app/services/project_service.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/services/project_service.js b/src/app/services/project_service.js index 1c351b7b..1151bf9e 100644 --- a/src/app/services/project_service.js +++ b/src/app/services/project_service.js @@ -292,7 +292,7 @@ angular objects.push({key: i, value: query}); } else if (search_keys[i] === 'object') { for (var column_name in obj[i]) { - // there a spark bug where columns are missign from the catalog. That needs to be fixed + // there is a spark bug where columns are missing from the catalog. That needs to be fixed // outside of docs but this if != null check will allow docs to continue to function now // and also when the bug is fixed. // relevant issue: https://github.com/dbt-labs/dbt-spark/issues/295 From 8efc465113a226e057f7a37fafc45ef9e77635b3 Mon Sep 17 00:00:00 2001 From: Doug Beatty Date: Thu, 9 Feb 2023 21:27:50 -0700 Subject: [PATCH 4/4] Changelog entry --- .changes/unreleased/Docs-20230209-212729.yaml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changes/unreleased/Docs-20230209-212729.yaml diff --git a/.changes/unreleased/Docs-20230209-212729.yaml b/.changes/unreleased/Docs-20230209-212729.yaml new file mode 100644 index 00000000..0ec0dca5 --- /dev/null +++ b/.changes/unreleased/Docs-20230209-212729.yaml @@ -0,0 +1,6 @@ +kind: Docs +body: Searchable column descriptions +time: 2023-02-09T21:27:29.570243-07:00 +custom: + Author: dbeatty10 + Issue: 140 322 369