From 01fe1cfafb066f3e1399fd7cb202b87e53f3296b Mon Sep 17 00:00:00 2001 From: Graham Lee Date: Wed, 29 Jun 2022 11:13:14 +0100 Subject: [PATCH] Refactor: use dataclasses to discover the date fields in dictionary conversion #2714 --- .../reusable_data_service/model/case.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/data-serving/reusable-data-service/reusable_data_service/model/case.py b/data-serving/reusable-data-service/reusable_data_service/model/case.py index cb5fd159a..98560af3d 100644 --- a/data-serving/reusable-data-service/reusable_data_service/model/case.py +++ b/data-serving/reusable-data-service/reusable_data_service/model/case.py @@ -91,9 +91,8 @@ def to_dict(self): @classmethod def date_fields(cls) -> list[str]: - """Record where dates are kept because they sometimes need special treatment. - A subclass could override this method to indicate it stores additional date fields.""" - return ["confirmationDate"] + """Record where dates are kept because they sometimes need special treatment.""" + return [f.name for f in dataclasses.fields(cls) if f.type == datetime.date] # Actually we want to capture extra fields which can be specified dynamically: