Skip to content

Commit

Permalink
Remove obsolete date field assignment (#81)
Browse files Browse the repository at this point in the history
* Remove obsolete date field assignment

We no longer have opensearch, so this is not needed. I have looked in
the backend and through the pipeline and can't find any instances of
it still being used. I've also left the field itself so it can still
be used if we have any more-legacy type code lying around

* bump version

* Add deprecated comment to obsolete field
  • Loading branch information
olaughter authored Aug 28, 2024
1 parent 00b4875 commit aead4ff
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 17 deletions.
18 changes: 2 additions & 16 deletions src/cpr_sdk/pipeline_general_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from enum import Enum
from typing import Mapping, Any, List, Optional, Sequence, Union

from pydantic import BaseModel, field_validator, model_validator
from pydantic import BaseModel, field_validator

Json = dict[str, Any]

Expand All @@ -29,7 +29,7 @@ class BackendDocument(BaseModel):
family_import_id: str
family_slug: str
publication_ts: datetime
date: Optional[str] = None # Set on import by a validator
date: Optional[str] = None # Deprecated
source_url: Optional[str] = None
download_url: Optional[str] = None
corpus_import_id: Optional[str] = None
Expand All @@ -45,20 +45,6 @@ class BackendDocument(BaseModel):

metadata: Json

@model_validator(mode="after")
def convert_publication_ts_to_date(self):
"""
Convert publication_ts to a datetime string.
This is necessary as OpenSearch expects a date object.
TODO: remove when no longer using Opensearch
"""

self.date = self.publication_ts.strftime("%d/%m/%Y")

return self

@field_validator("type", mode="before")
@classmethod
def none_to_empty_string(cls, value):
Expand Down
2 changes: 1 addition & 1 deletion src/cpr_sdk/version.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
_MAJOR = "1"
_MINOR = "3"
_PATCH = "10"
_PATCH = "11"
_SUFFIX = ""

VERSION_SHORT = "{0}.{1}".format(_MAJOR, _MINOR)
Expand Down

0 comments on commit aead4ff

Please sign in to comment.