Skip to content

Commit

Permalink
Merge pull request #98 from NatLibFi/analytics_exporter_fix
Browse files Browse the repository at this point in the history
Fix max_contribs calculation to handle None values
  • Loading branch information
natlibfi-psams authored Sep 26, 2024
2 parents d10ee45 + 7c79573 commit b960631
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions api/local_analytics_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ def export_excel(self, _db, start, end, locations=None, library=None):
rows = [dict(row) for row in results]

# Count how many contributor rows we need
max_contribs = max([0, *[len(row.get("contributors", [])) for row in rows]])
max_contribs = max(
[0, *[len(row.get("contributors", []) or []) for row in rows]]
)

header = [
"Tekijä (aakkostus)",
Expand All @@ -99,8 +101,7 @@ def export_excel(self, _db, start, end, locations=None, library=None):
genres = row.get("genres")
categories = ", ".join(genres) if genres else ""

contributors = row.get("contributors", [])

contributors = row.get("contributors") or []
sheet.append(
[
# Tekijä (aakkostus)
Expand Down

0 comments on commit b960631

Please sign in to comment.