Skip to content

Commit

Permalink
Merge pull request #600 from wri/feature/GTC_3007
Browse files Browse the repository at this point in the history
GTC-3007 Add content-date-description metadata field
  • Loading branch information
manukala6 authored Oct 31, 2024
2 parents 50c4642 + d0acafc commit 14f51c5
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 1 deletion.
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

0 comments on commit 14f51c5

Please sign in to comment.