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

GTC-3007 Add content-date-description metadata field #600

Merged
merged 1 commit into from
Oct 31, 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
29 changes: 29 additions & 0 deletions app/models/orm/migrations/versions/604bf4e66c2b_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"""Add content_date_description to version_metadata

Revision ID: 604bf4e66c2b
Revises: ef3392e8e054
Create Date: 2024-10-31 16:52:56.571782

"""
from alembic import op
import sqlalchemy as sa
import sqlalchemy_utils
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = '604bf4e66c2b'
down_revision = 'ef3392e8e054'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('version_metadata', sa.Column('content_date_description', sa.String(), nullable=True))
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('version_metadata', 'content_date_description')
# ### end Alembic commands ###
1 change: 1 addition & 0 deletions app/models/orm/version_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class VersionMetadata(Base, MetadataMixin):
version = db.Column(db.String, nullable=False)
content_date = db.Column(db.Date)
content_start_date = db.Column(db.Date)
content_date_description = db.Column(db.String)
content_end_date = db.Column(db.Date)
last_update = db.Column(db.Date)
description = db.Column(db.String)
Expand Down
10 changes: 9 additions & 1 deletion app/models/pydantic/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,10 @@ class VersionMetadata(CommonMetadata):
None,
description="Date range covered by the content",
)

content_date_description: Optional[str] = Field(
None,
description="Date of content to display",
)
last_update: Optional[date] = Field(
None,
description="Date the data were last updated",
Expand All @@ -130,6 +133,7 @@ class Config:
"start_date": "2000-01-01", # TODO fix date
"end_date": "2021-04-06",
},
"content_date_description": "2000 - present",
}
]
}
Expand Down Expand Up @@ -159,6 +163,10 @@ class VersionMetadataUpdate(VersionMetadataIn):
None,
description="Date range covered by the content",
)
content_date_description: Optional[str] = Field(
None,
description="Date of content to display",
)

last_update: Optional[date] = Field(
None,
Expand Down
1 change: 1 addition & 0 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

version_metadata = {
"content_date_range": {"start_date": "2000-01-01", "end_date": "2021-01-01"},
"content_date_description": "2000 - present",
"last_update": "2020-01-03",
"spatial_resolution": 10,
"resolution_description": "10 meters",
Expand Down
1 change: 1 addition & 0 deletions tests_v2/fixtures/metadata/version.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
VERSION_METADATA = {
"content_date_range": {"start_date": "2000-01-01", "end_date": "2021-01-01"},
"content_date_description": "2000 - present",
"last_update": "2020-01-03",
"spatial_resolution": 10,
"resolution_description": "10 meters",
Expand Down
Loading