Skip to content

Commit

Permalink
Belga archive API: Provide first published timestamp for items of typ…
Browse files Browse the repository at this point in the history
…e related [SDBELGA-631] (#424)

* populated all fields with data['comment']

* fix testcases
  • Loading branch information
devketanpro authored and petrjasek committed Feb 27, 2023
1 parent fd5f493 commit 5fb104f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions server/belga/search_providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,11 +548,11 @@ def format_list_item(self, data):
"ednote": get_text(data.get("editorialInfo")),
}
if data.get("assetType") == "RelatedArticle" and data.get("comments"):
formatted_data["versioncreated"] = formatted_data[
"firstpublished"
] = get_datetime(datetime.strptime(data.get("comments"), "%Y%m%d%H%M%S"))
if not data.get("createDate"):
formatted_data["firstcreated"] = formatted_data["firstpublished"]
formatted_data["firstcreated"] = formatted_data[
"versioncreated"
] = formatted_data["firstpublished"] = get_datetime(
datetime.strptime(data.get("comments"), "%Y%m%d%H%M%S")
)

return formatted_data

Expand Down
2 changes: 1 addition & 1 deletion server/tests/search_providers/belga_360_archive_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ def test_get_related_article(self):
self.assertEqual(item["source"], "BELGA")
self.assertEqual(item["language"], "fr")
self.assertEqual(
item["firstcreated"], datetime.fromtimestamp(1638953020, utc)
item["firstcreated"], datetime(2022, 10, 5, 13, 41, 50, tzinfo=utc)
)
self.assertEqual(
item["versioncreated"], datetime(2022, 10, 5, 13, 41, 50, tzinfo=utc)
Expand Down

0 comments on commit 5fb104f

Please sign in to comment.