Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #49 from climatepolicyradar/feature/extend-backend…
Browse files Browse the repository at this point in the history
…-document-type

Add family_slug to BackendDocument
  • Loading branch information
joel-wright authored Oct 10, 2023
2 parents 1b451e3 + 62c4d3e commit a337bf7
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
5 changes: 4 additions & 1 deletion src/cpr_data_access/pipeline_general_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ class BackendDocument(BaseModel):
name: str
description: str
import_id: str
family_import_id: str
slug: str
family_import_id: str
family_slug: str
publication_ts: datetime
date: Optional[str] = None # Set on import by a validator
source_url: Optional[str]
Expand All @@ -46,6 +47,8 @@ def convert_publication_ts_to_date(cls, values):
Convert publication_ts to a datetime string.
This is necessary as OpenSearch expects a date object.
TODO: remove when no longer using Opensearch
"""

values["date"] = values["publication_ts"].strftime("%d/%m/%Y")
Expand Down
3 changes: 2 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ def backend_document_json() -> dict:
"name": "test_name",
"description": "test_description",
"import_id": "test_import_id",
"family_import_id": "test_family_import_id",
"slug": "test_slug",
"family_import_id": "test_family_import_id",
"family_slug": "test_family_slug",
"publication_ts": "2021-01-01T00:00:00+00:00",
"date": "01/01/2021",
"source_url": "test_source_url",
Expand Down
3 changes: 2 additions & 1 deletion tests/test_data/valid/test_html.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
"name": "test_html",
"description": "test_html_description",
"import_id": "CCLW.executive.1001.0",
"family_import_id": "CCLW.executive.1001",
"slug": "test_html",
"family_import_id": "CCLW.executive.1001",
"family_slug": "test_html_family",
"publication_ts": "2022-10-25 12:43:00.869045",
"source_url": "https://www.industry.gov.au/funding-and-incentives/emissions-reduction-fund",
"download_url": "https://www.industry.gov.au/funding-and-incentives/emissions-reduction-fund",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
"name": "test_no_content_type",
"description": "test_no_content_type_description",
"import_id": "CCLW.executive.1002.0",
"family_import_id": "CCLW.executive.1002",
"slug": "test_pdf",
"family_import_id": "CCLW.executive.1002",
"family_slug": "test_pdf_family",
"publication_ts": "2022-10-25 12:43:00.869045",
"source_url": "https://cdn.climatepolicyradar.org/EUR/2013/EUR-2013-01-01-Overview+of+CAP+Reform+2014-2020_6237180d8c443d72c06c9167019ca177.pdf",
"download_url": "https://cdn.climatepolicyradar.org/EUR/2013/EUR-2013-01-01-Overview+of+CAP+Reform+2014-2020_6237180d8c443d72c06c9167019ca177.pdf",
Expand Down
3 changes: 2 additions & 1 deletion tests/test_data/valid/test_pdf.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
"name": "test_pdf",
"description": "test_pdf_description",
"import_id": "CCLW.executive.1003.0",
"family_import_id": "CCLW.executive.1003",
"slug": "test_pdf",
"family_import_id": "CCLW.executive.1003",
"family_slug": "test_pdf_family",
"publication_ts": "2022-10-25 12:43:00.869045",
"source_url": "https://cdn.climatepolicyradar.org/EUR/2013/EUR-2013-01-01-Overview+of+CAP+Reform+2014-2020_6237180d8c443d72c06c9167019ca177.pdf",
"download_url": "https://cdn.climatepolicyradar.org/EUR/2013/EUR-2013-01-01-Overview+of+CAP+Reform+2014-2020_6237180d8c443d72c06c9167019ca177.pdf",
Expand Down

0 comments on commit a337bf7

Please sign in to comment.