From 6711354f21c37d776ed013db007e120e3465d122 Mon Sep 17 00:00:00 2001 From: Henri Hemminki Date: Fri, 29 Apr 2022 13:19:15 +0300 Subject: [PATCH] Added manifest sorting by created time. This allows better functionality with max_files_in_manifest parameter --- adenotifier/notifier.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/adenotifier/notifier.py b/adenotifier/notifier.py index 8abf3a6..f79369f 100644 --- a/adenotifier/notifier.py +++ b/adenotifier/notifier.py @@ -33,6 +33,8 @@ def search_manifests(source_system_name: str, source_entity_name: str, state: st raise Exception(e) manifests = response.json() + # Ordering manifests by created time + manifests = (sorted(manifests, key = lambda i: i['created'])) manifest_ids = [] for manifest in manifests: @@ -148,10 +150,11 @@ def add_to_manifest(file_url: str, source: object, base_url: str, notify_api_key base_url = base_url, notify_api_key = notify_api_key, notify_api_key_secret = notify_api_key_secret, - manifest_id = manifest.id[0] + manifest_id = manifest.id ) if (len(manifest_entries) >= source['attributes']['max_files_in_manifest']): + logging.info('Max files in manifest reached. Creating a new manifest') # Create a new manifest if current manifest has already reached max files limit manifest.create() logging.info('Manifest created: {0}'.format(manifest.id))