Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fmd 471 display table name only #518

Merged
merged 9 commits into from
Jul 3, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,13 @@ query Search(
platform {
name
}
container {
urn
properties {
name
qualifiedName
}
}
subTypes {
typeNames
}
Expand Down
12 changes: 11 additions & 1 deletion lib/datahub-client/data_platform_catalogue/client/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
parse_properties,
parse_tags,
)
from data_platform_catalogue.entities import EntityRef
from data_platform_catalogue.search_types import (
FacetOption,
MultiSelectFilter,
Expand Down Expand Up @@ -231,7 +232,11 @@ def _parse_result(
terms = parse_glossary_terms(entity)
last_modified = parse_last_modified(entity)
name, display_name, qualified_name = parse_names(entity, properties)

container = entity.get("container")
if container:
container_name, container_display_name, container_qualified_name = (
parse_names(container, container.get("properties"))
)
domain = parse_domain(entity)

metadata = {
Expand All @@ -257,6 +262,11 @@ def _parse_result(
name=name,
display_name=display_name,
fully_qualified_name=qualified_name,
parent_entity=(
EntityRef(urn=container.get("urn"), display_name=container_display_name)
if container
else None
),
description=properties.get("description", ""),
metadata=metadata,
tags=tags,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from enum import Enum, auto
from typing import Any

from data_platform_catalogue.entities import GlossaryTermRef, TagRef
from data_platform_catalogue.entities import EntityRef, GlossaryTermRef, TagRef


class ResultType(Enum):
Expand Down Expand Up @@ -68,6 +68,7 @@ class SearchResult:
glossary_terms: list[GlossaryTermRef] = field(default_factory=list)
last_modified: datetime | None = None
created: datetime | None = None
parent_entity: EntityRef | None = None
tags_to_display: list[str] = field(init=False)

def __post_init__(self):
Expand Down
10 changes: 10 additions & 0 deletions lib/datahub-client/tests/client/datahub/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from data_platform_catalogue.entities import (
AccessInformation,
DataSummary,
EntityRef,
FurtherInformation,
TagRef,
UsageRestrictions,
Expand Down Expand Up @@ -79,6 +80,13 @@ def test_one_search_result(mock_graph, searcher):
"type": "DATASET",
"urn": "urn:li:dataset:(urn:li:dataPlatform:bigquery,calm-pagoda-323403.jaffle_shop.customers,PROD)", # noqa E501
"platform": {"name": "bigquery"},
"container": {
"urn": "urn:li:container:abc",
"properties": {
"name": "abc",
"qualifiedName": None,
},
},
"ownership": None,
"name": "calm-pagoda-323403.jaffle_shop.customers",
"properties": {
Expand Down Expand Up @@ -140,6 +148,7 @@ def test_one_search_result(mock_graph, searcher):
tags=[],
last_modified=None,
created=None,
parent_entity=EntityRef(urn="urn:li:container:abc", display_name="abc"),
)
],
facets=SearchFacets(facets={}),
Expand All @@ -161,6 +170,7 @@ def test_dataset_result(mock_graph, searcher):
"type": "DATASET",
"urn": "urn:li:dataset:(urn:li:dataPlatform:bigquery,calm-pagoda-323403.jaffle_shop.customers,PROD)", # noqa E501
"platform": {"name": "bigquery"},
"container": None,
"ownership": None,
"name": "calm-pagoda-323403.jaffle_shop.customers",
"properties": {
Expand Down
24 changes: 15 additions & 9 deletions templates/partial/search_result.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<div class="govuk-grid-column-full">
<h3 class="govuk-heading-m govuk-!-margin-bottom-2">
{% with result_type=result.result_type.name|lower %}
<a href="{% url 'home:details' result_type=result_type urn=result.urn %}" class="govuk-link">{{result.fully_qualified_name}}</a>
<a href="{% url 'home:details' result_type=result_type urn=result.urn %}" class="govuk-link">{{result.name}}</a>
{% endwith %}
{% if result.result_type.name == "TABLE" %}
<strong class="govuk-tag govuk-!-margin-left-2">
Expand All @@ -34,19 +34,25 @@ <h3 class="govuk-heading-m govuk-!-margin-bottom-2">
<span>TBC</span>
</li>
<li>
<span class="govuk-!-font-weight-bold">Domain name:</span>
<span class="govuk-!-font-weight-bold">Domain:</span>
<span>{{result.metadata.domain_name}}</span>
</li>
<li>
{% if result.result_type.name == "TABLE" %}
<li>
<span class="govuk-!-font-weight-bold">Database:</span>
<span>{{result.parent_entity.display_name}}</span>
</li>
{% endif %}
<li>
<span class="govuk-!-font-weight-bold">Tags:</span>
<span>
{% if result.tags_to_display %}
{% for tag in result.tags_to_display %}
<a aria-label="link to search results for all entities tagged {{ tag }}" href="{% url 'home:search' %}{% query_string clear_label=None clear_filter=None new=None tags=tag %}">{{ tag }}</a>{% if not forloop.last %}, {% endif %}
{% endfor %}
{% endif %}
{% if result.tags_to_display %}
{% for tag in result.tags_to_display %}
<a aria-label="link to search results for all entities tagged {{ tag }}" href="{% url 'home:search' %}{% query_string clear_label=None clear_filter=None new=None tags=tag %}">{{ tag }}</a>{% if not forloop.last %}, {% endif %}
{% endfor %}
{% endif %}
</span>
</li>
</li>
{% if result.matches %}
<li>
<span class="govuk-!-font-weight-bold">Matched fields:</span>
Expand Down
Loading