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

Restrict search to indexed fields #601

Merged
merged 14 commits into from
May 22, 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
4 changes: 2 additions & 2 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
version: 2
build:
os: ubuntu-20.04
os: ubuntu-22.04
tools:
python: "3.8"
python: "3.10"
apt_packages:
- libgdal-dev
- gdal-bin
Expand Down
10 changes: 5 additions & 5 deletions cubedash/_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import flask
import pytz
from datacube.index.fields import Field
from datacube.model import Dataset, DatasetType, Range
from datacube.model import Dataset, Product, Range
Ariana-B marked this conversation as resolved.
Show resolved Hide resolved
from dateutil import tz
from flask import Blueprint
from markupsafe import Markup, escape
Expand Down Expand Up @@ -226,7 +226,7 @@ def _max_val(ls):


@bp.app_template_filter("product_license_link")
def _product_license(product: DatasetType):
def _product_license(product: Product):
license_ = _utils.product_license(product)

if license_ is None:
Expand All @@ -244,7 +244,7 @@ def _product_license(product: DatasetType):


@bp.app_template_filter("searchable_fields")
def _searchable_fields(product: DatasetType):
def _searchable_fields(product: Product):
"""Searchable field names for a product"""

# No point searching fields that are fixed for this product
Expand All @@ -254,12 +254,12 @@ def _searchable_fields(product: DatasetType):
return sorted(
(key, field)
for key, field in product.metadata_type.dataset_fields.items()
if key not in skippable_product_keys and key != "product"
if key not in skippable_product_keys and key != "product" and field.indexed
)


@bp.app_template_filter("searchable_fields_keys")
def _searchable_fields_keys(product: DatasetType):
def _searchable_fields_keys(product: Product):
"""List of keys of searchable field names for a product"""
fields = _searchable_fields(product)
return [k for k, _ in fields]
Expand Down
47 changes: 35 additions & 12 deletions cubedash/templates/metadata-type.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,42 @@ <h3>
</h3>
<div class="{% if metadata_type.dataset_fields | length > 8 %}columned{% endif %}">
{% for key, field in metadata_type.dataset_fields | dictsort %}
<div>
{{ key }}
{%- if field.indexed is true %}
<div>
{{ key }}

<span class="badge">
{{- field.type_name -}}
{%- if field.indexed is true %}
<span title="indexed"><i class="fa fa-square" aria-hidden="true"></i></span>
{%- endif -%}
</span>
{% if field.description and ('TODO' not in field.description) %}
<span class="muted">{{ field.description }}</span>
{% endif %}
</div>
<span class="badge">
{{- field.type_name -}}
</span>
{% if field.description and ('TODO' not in field.description) %}
<span class="muted">{{ field.description }}</span>
{% endif %}
</div>
{%- endif -%}
{% endfor %}
</div>
</div>


<div class="panel">
<h3>
Additional Fields
{{ hanchor('additional-fields') }}
</h3>
<div class="{% if metadata_type.dataset_fields | length > 8 %}columned{% endif %}">
{% for key, field in metadata_type.dataset_fields | dictsort %}
{%- if field.indexed is false %}
<div>
{{ key }}

<span class="badge">
{{- field.type_name -}}
</span>
{% if field.description and ('TODO' not in field.description) %}
<span class="muted">{{ field.description }}</span>
{% endif %}
</div>
{%- endif -%}
{% endfor %}
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion cubedash/testutils/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def postgresql_server():
else:
client = docker.from_env()
container = client.containers.run(
"postgis/postgis:14-3.3-alpine",
"postgis/postgis:16-3.4",
auto_remove=True,
remove=True,
detach=True,
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ services:
- postgres

postgres:
image: postgis/postgis:13-3.4
image: postgis/postgis:16-3.4
hostname: postgres
environment:
- POSTGRES_DB=opendatacube
Expand Down
2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ autodocsumm==0.2.9
beautifulsoup4==4.11.0
nbsphinx==0.8.9
pydata-sphinx-theme==0.9.0
Sphinx==4.5.0
Sphinx==5.0.0
sphinx-autodoc-typehints==1.19.0
sphinx-click==4.2.0
Loading
Loading