From e13403b59245c8b2f2318f2213a35cdbc924fcb2 Mon Sep 17 00:00:00 2001 From: Beda Kosata Date: Mon, 15 Mar 2021 11:05:15 +0100 Subject: [PATCH] allow Item_ID to be null in C5 data --- apps/nigiri/counter5.py | 3 ++- apps/sushi/management/commands/validate_sushi_json.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/nigiri/counter5.py b/apps/nigiri/counter5.py index d892e08e..c0389d46 100644 --- a/apps/nigiri/counter5.py +++ b/apps/nigiri/counter5.py @@ -98,7 +98,8 @@ def read_report(self, report: dict) -> [CounterRecord]: record = CounterRecord() record.platform_name = item.get('Platform') record.title = self._item_get_title(item) - record.title_ids = self._extract_title_ids(item.get('Item_ID', [])) + # Item_ID can (should not, but can) be null, so we use get() or [] to handle it + record.title_ids = self._extract_title_ids(item.get('Item_ID') or []) record.dimension_data = self._extract_dimension_data(self.dimensions, item) performances = item.get('Performance') for performance in performances: diff --git a/apps/sushi/management/commands/validate_sushi_json.py b/apps/sushi/management/commands/validate_sushi_json.py index 1682c9d5..c2d0461f 100644 --- a/apps/sushi/management/commands/validate_sushi_json.py +++ b/apps/sushi/management/commands/validate_sushi_json.py @@ -48,7 +48,7 @@ def handle(self, *args, **options): def item_to_key(cls, item): key_keys = ['Title', 'Platform'] item_key = [item.get(key) for key in key_keys] - item_ids = item.get('Item_ID', []) + item_ids = item.get('Item_ID') or [] for key in Counter5TRReport.allowed_item_ids: for item_id in item_ids: if item_id.get('Type') == key: