From b006c4b73c7503630594c4f22eeec3f1c01305db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20tom=20W=C3=B6rden?= <h.tomwoerden@indiscale.com> Date: Thu, 8 Sep 2022 18:00:54 +0200 Subject: [PATCH] MAINT: added doc and return value to authorize_changes" --- src/caosadvancedtools/cache.py | 4 ++-- src/caosadvancedtools/crawler.py | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/caosadvancedtools/cache.py b/src/caosadvancedtools/cache.py index 85e2afff..0aef80de 100644 --- a/src/caosadvancedtools/cache.py +++ b/src/caosadvancedtools/cache.py @@ -349,12 +349,12 @@ class UpdateCache(AbstractCache): return old_ones def insert(self, cont, run_id, insert=False): - """Insert a pending, unauthorized inserts + """Insert a pending, unauthorized insert or update Parameters ---------- - cont: Container with the records to be inserted containing the desired + cont: Container with the records to be inserted or updated containing the desired version, i.e. the state after the update. run_id: int diff --git a/src/caosadvancedtools/crawler.py b/src/caosadvancedtools/crawler.py index 6a0cdb58..2fac6243 100644 --- a/src/caosadvancedtools/crawler.py +++ b/src/caosadvancedtools/crawler.py @@ -210,11 +210,14 @@ class Crawler(object): """ cache = UpdateCache() inserts = cache.get_inserts(run_id) + all_inserts = 0 + all_updates = 0 for _, _, _, new, _ in inserts: new_cont = db.Container() new_cont = new_cont.from_xml(new) new_cont.insert(unique=False) logger.info("Successfully inserted {} records!".format(len(new_cont))) + all_inserts += len(new_cont) logger.info("Finished with authorized updates.") changes = cache.get_updates(run_id) @@ -238,7 +241,9 @@ class Crawler(object): new_cont.update(unique=False) logger.info("Successfully updated {} records!".format( len(new_cont))) + all_updates += len(new_cont) logger.info("Finished with authorized updates.") + return all_inserts, all_updates def collect_cfoods(self): """ -- GitLab