From 7b2c597a240d53ca2eca83dddc36dea7b7c0e80b Mon Sep 17 00:00:00 2001 From: Logan Williams Date: Thu, 2 Mar 2023 16:45:38 +0100 Subject: [PATCH] Update channel source, only if non-researcher --- cisticola/transformer/base.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cisticola/transformer/base.py b/cisticola/transformer/base.py index b83124a..44f867e 100644 --- a/cisticola/transformer/base.py +++ b/cisticola/transformer/base.py @@ -150,6 +150,15 @@ class ETLController: if instance: logger.info(f"Found matching DB entry for {obj}: {instance}") + + if type(obj) == Channel: + if obj.source != instance.source and obj.source == 'linked_channel' and instance.source != 'researcher': + logger.info(f"Updating source to linked channel") + instance.source = obj.source + instance.notes = obj.notes + session.flush() + session.commit() + return instance # Don't hydrate videos, because they can be quite large and this is time consuming