Skip to content

Commit

Permalink
Merge pull request #143 from SUSE-Enceladus/append-record-doc
Browse files Browse the repository at this point in the history
Add full docstring to function
  • Loading branch information
smarlowucf authored Jan 9, 2024
2 parents 086223a + a2f4c85 commit f342b84
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions csp_billing_adapter/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,27 @@

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. If archive ends up greater
than max lengh the first (oldest) record is dropped.
"""
archive.append(records)
archive.append(billing_record)

if len(archive) > max_length:
return archive[1:]
Expand Down

0 comments on commit f342b84

Please sign in to comment.