Skip to content

Commit

Permalink
Added manifest sorting by created time. This allows better functional…
Browse files Browse the repository at this point in the history
…ity with max_files_in_manifest parameter
  • Loading branch information
henrihem committed Apr 29, 2022
1 parent 4384e21 commit 6711354
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion adenotifier/notifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit 6711354

Please sign in to comment.