From b5b7bb4f550770c871cafc4a2bdd8eab96d0e5f8 Mon Sep 17 00:00:00 2001 From: marwoodandrew Date: Fri, 4 Nov 2022 12:12:21 +1100 Subject: [PATCH] [SDAAP-42] fix 360info parser --- .../aap/io/feed_parsers/three_sixty_ninjs.py | 20 ++++++++--------- server/features/sms_report.feature | 22 +++++++++---------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/server/aap/io/feed_parsers/three_sixty_ninjs.py b/server/aap/io/feed_parsers/three_sixty_ninjs.py index f6fbb939f..3f04469af 100644 --- a/server/aap/io/feed_parsers/three_sixty_ninjs.py +++ b/server/aap/io/feed_parsers/three_sixty_ninjs.py @@ -65,19 +65,19 @@ def _transform_from_ninjs(self, ninjs): for _key, associated_item in item.get('associations', {}).items(): if associated_item: if associated_item.get('type') == 'picture': - - # fix to pass validation - associated_item['headline'] = associated_item.get('headline', '')[:42] if len( - associated_item.get('headline', '')) > 42 else associated_item.get('headline', 'No Headline') - if associated_item['headline'] == '': - associated_item['headline'] = 'No Headline' - associated_item['alt_text'] = associated_item['headline'] - associated_item['description_text'] = associated_item.get('description_text', '')[:100] if len( - associated_item.get('description_text', '')) > 100 else associated_item.get('description_text', - 'No Caption') # renditions will be set from the ingested image associated_item.pop('renditions', None) + if ninjs.get('type') == 'picture': + # fix to pass validation + item['headline'] = ninjs.get('headline', '')[:42] + if not item['headline']: + item['headline'] = 'No Headline' + item['alt_text'] = item['headline'] + item['description_text'] = ninjs.get('description_text', '')[:100] + if not item['description_text']: + item['description_text'] = 'No Caption' + if ninjs.get('type') == 'text': # add marketplace keyword diff --git a/server/features/sms_report.feature b/server/features/sms_report.feature index 10455532f..c14ecbf0a 100644 --- a/server/features/sms_report.feature +++ b/server/features/sms_report.feature @@ -21,7 +21,7 @@ Feature: SMS Report Then we get list with 1 items """ {"_items": [{ - "start_epoch": 1530223200000, + "start_epoch": 1530226800000, "interval": 86400000, "with_sms": [0, 1, 1], "without_sms": [1, 1, 0] @@ -71,14 +71,14 @@ Feature: SMS Report "type": "column", "xAxis": 0, "data": [0, 1, 1], - "pointStart": 1530223200000, + "pointStart": 1530226800000, "pointInterval": 86400000 }, { "name": "Without SMS", "type": "column", "xAxis": 0, "data": [1, 1, 0], - "pointStart": 1530223200000, + "pointStart": 1530226800000, "pointInterval": 86400000 }] }] @@ -106,7 +106,7 @@ Feature: SMS Report Then we get list with 1 items """ {"_items": [{ - "start_epoch": 1530309600000, + "start_epoch": 1530313200000, "interval": 3600000, "with_sms": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0], "without_sms": [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] @@ -155,15 +155,15 @@ Feature: SMS Report "name": "With SMS", "type": "column", "xAxis": 0, - "data": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0], - "pointStart": 1530309600000, + "data": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0], + "pointStart": 1530313200000, "pointInterval": 3600000 }, { "name": "Without SMS", "type": "column", "xAxis": 0, - "data": [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - "pointStart": 1530309600000, + "data": [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + "pointStart": 1530313200000, "pointInterval": 3600000 }] }] @@ -194,7 +194,7 @@ Feature: SMS Report Then we get list with 1 items """ {"_items": [{ - "start_epoch": 1529186400000, + "start_epoch": 1529190000000, "interval": 604800000, "with_sms": [1, 2], "without_sms": [1, 1] @@ -247,14 +247,14 @@ Feature: SMS Report "type": "column", "xAxis": 0, "data": [1, 2], - "pointStart": 1529186400000, + "pointStart": 1529190000000, "pointInterval": 604800000 }, { "name": "Without SMS", "type": "column", "xAxis": 0, "data": [1, 1], - "pointStart": 1529186400000, + "pointStart": 1529190000000, "pointInterval": 604800000 }] }]