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

set expiry when parsing onclusive events #1995

Merged
merged 2 commits into from
Jun 4, 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
9 changes: 9 additions & 0 deletions server/planning/feed_parsers/onclusive.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def parse(self, content, provider=None):
self.parse_event_details(event, item)
self.parse_category(event, item)
self.parse_contact_info(event, item)
self.set_expiry(item, provider)
all_events.append(item)
except EmbargoedException:
logger.info("Ignoring embargoed event %s", event["itemId"])
Expand Down Expand Up @@ -303,3 +304,11 @@ def parse_contact_info(self, event, item):
existing_contact_id = bson.ObjectId(existing_contact["_id"])
get_resource_service("contacts").patch(existing_contact_id, data)
item["event_contact_info"].append(existing_contact_id)

def set_expiry(self, event, provider) -> None:
expiry_minutes = (
int(provider.get("content_expiry") if provider else 0)
or int(app.config.get("INGEST_EXPIRY_MINUTES", 0))
or (60 * 24)
)
event["expiry"] = event["dates"]["end"] + datetime.timedelta(minutes=(expiry_minutes))
2 changes: 2 additions & 0 deletions server/planning/feed_parsers/onclusive_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ def test_content(self):
item = OnclusiveFeedParser().parse([data])[0]
self.assertEqual(item["occur_status"]["qcode"], "eocstat:eos3")

self.assertGreater(item["expiry"], item["dates"]["end"])

def test_content_no_time(self):
data = self.data.copy()
data["time"] = ""
Expand Down
Loading