in migration/src/jira_util.py [0:0]
def extract_attachments(o: dict) -> list[tuple[str, int]]:
attachments = o.get("fields").get("attachment")
if not attachments:
return []
files = {}
counts = defaultdict(int)
for a in attachments:
filename = a.get("filename")
created = a.get("created")
content = a.get("content")
mime_type = a.get("mimeType")
if not (filename and created and content and mime_type):
continue
if filename not in files or created > files[filename].created:
files[filename] = Attachment(filename=filename, created=created, content=content, mime_type=mime_type)
counts[filename] += 1
result = []
for name in files.keys():
result.append((name, counts[name]))
return result