summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2019-09-03 14:13:37 -0700
committerBryan Newbold <bnewbold@robocracy.org>2019-09-03 14:13:37 -0700
commit7690ee86e58d258b8f14ad33927037d7f06e2c67 (patch)
tree2e3e851bb53ce4844091dfabf992fff9c71d1823
parenta24ca520d1eafae302762a7b0f6eea0b01ef186a (diff)
downloadfatcat-7690ee86e58d258b8f14ad33927037d7f06e2c67.tar.gz
fatcat-7690ee86e58d258b8f14ad33927037d7f06e2c67.zip
more careful chocula import counts; don't re-update empty URLs
-rw-r--r--python/fatcat_tools/importers/chocula.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/python/fatcat_tools/importers/chocula.py b/python/fatcat_tools/importers/chocula.py
index 89b0736d..25edccee 100644
--- a/python/fatcat_tools/importers/chocula.py
+++ b/python/fatcat_tools/importers/chocula.py
@@ -80,9 +80,11 @@ class ChoculaImporter(EntityImporter):
except fatcat_client.rest.ApiException as err:
if err.status != 404:
raise err
+ self.counts['exists'] += 1
self.counts['exists-not-found'] += 1
return False
if existing.state != 'active':
+ self.counts['exists'] += 1
self.counts['exists-inactive'] += 1
return False
@@ -94,6 +96,7 @@ class ChoculaImporter(EntityImporter):
if err.status != 404:
raise err
if existing:
+ self.counts['exists'] += 1
self.counts['exists-by-issnl'] += 1
return False
# doesn't exist, always create
@@ -103,7 +106,7 @@ class ChoculaImporter(EntityImporter):
do_update = False
if not existing.extra:
existing.extra = dict()
- if set(ce.extra.get('urls', [])) != set(existing.extra.get('urls', [])):
+ if ce.extra.get('urls') and set(ce.extra.get('urls', [])) != set(existing.extra.get('urls', [])):
do_update = True
if ce.publisher and not existing.publisher:
do_update = True
@@ -128,7 +131,8 @@ class ChoculaImporter(EntityImporter):
self.counts['update'] += 1
return False
else:
- self.counts['skip-update'] += 1
+ self.counts['exists'] += 1
+ self.counts['exists-skip-update'] += 1
return False
# if we got this far, it's a bug