From 9d6df943cb6dc3a0f97a448efc8124119875c810 Mon Sep 17 00:00:00 2001 From: Sean Marlow Date: Tue, 9 Jan 2024 15:10:16 -0500 Subject: [PATCH 1/2] Add full docstring to function --- csp_billing_adapter/archive.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/csp_billing_adapter/archive.py b/csp_billing_adapter/archive.py index d9e3124..2ce0c5d 100644 --- a/csp_billing_adapter/archive.py +++ b/csp_billing_adapter/archive.py @@ -19,13 +19,26 @@ def append_metering_records( archive: list, - records: dict, + billing_record: dict, max_length: int -): +) -> list: """ - Append metering records to the archive while maintaining max length. + Append usage and metering records to the archive + + If archive is larger than max length, drop the oldest record. + + :param archive: + The list of meterings and usage records to append to. + :param billing_record: + The dictionary containing the most recent + metering and usage records to be archived. + :param max_length: + The max size of the archive list. + :return: + The archive of meterings and usage records with the + billing_record appended. """ - archive.append(records) + archive.append(billing_record) if len(archive) > max_length: return archive[1:] From a2f4c8575b35d03f421cdbee2a50bddf73363e29 Mon Sep 17 00:00:00 2001 From: Sean Marlow Date: Tue, 9 Jan 2024 16:48:20 -0500 Subject: [PATCH 2/2] Include comment about max length handling In the return section of docstring. --- csp_billing_adapter/archive.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/csp_billing_adapter/archive.py b/csp_billing_adapter/archive.py index 2ce0c5d..d86ac6a 100644 --- a/csp_billing_adapter/archive.py +++ b/csp_billing_adapter/archive.py @@ -36,7 +36,8 @@ def append_metering_records( The max size of the archive list. :return: The archive of meterings and usage records with the - billing_record appended. + billing_record appended. If archive ends up greater + than max lengh the first (oldest) record is dropped. """ archive.append(billing_record)