Skip to content
Snippets Groups Projects
Commit 7f8604d3 authored by Alexander Schlemmer's avatar Alexander Schlemmer
Browse files

Merge branch 'f-fix-circular' into 'dev'

parents ff3b107d 9bad45f4
No related branches found
No related tags found
2 merge requests!71REL: RElease v0.2.0,!58FIX https://gitlab.com/caosdb/caosdb-crawler/-/issues/30
Pipeline #29607 passed
...@@ -16,6 +16,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ...@@ -16,6 +16,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Removed ### ### Removed ###
### Fixed ### ### Fixed ###
* FIX: https://gitlab.com/caosdb/caosdb-crawler/-/issues/30
### Security ### ### Security ###
......
...@@ -500,7 +500,8 @@ class Crawler(object): ...@@ -500,7 +500,8 @@ class Crawler(object):
return True return True
return False return False
def create_flat_list(self, ent_list: List[db.Entity], flat: List[db.Entity]): @staticmethod
def create_flat_list(ent_list: List[db.Entity], flat: List[db.Entity]):
""" """
Recursively adds all properties contained in entities from ent_list to Recursively adds all properties contained in entities from ent_list to
the output list flat. Each element will only be added once to the list. the output list flat. Each element will only be added once to the list.
...@@ -516,13 +517,11 @@ class Crawler(object): ...@@ -516,13 +517,11 @@ class Crawler(object):
if isinstance(el, db.Entity): if isinstance(el, db.Entity):
if el not in flat: if el not in flat:
flat.append(el) flat.append(el)
# TODO: move inside if block? Crawler.create_flat_list([el], flat)
self.create_flat_list([el], flat)
elif isinstance(p.value, db.Entity): elif isinstance(p.value, db.Entity):
if p.value not in flat: if p.value not in flat:
flat.append(p.value) flat.append(p.value)
# TODO: move inside if block? Crawler.create_flat_list([p.value], flat)
self.create_flat_list([p.value], flat)
def has_missing_object_in_references(self, record: db.Record): def has_missing_object_in_references(self, record: db.Record):
""" """
...@@ -696,7 +695,7 @@ class Crawler(object): ...@@ -696,7 +695,7 @@ class Crawler(object):
to_be_updated: List[db.Entity] = [] to_be_updated: List[db.Entity] = []
flat = list(ent_list) flat = list(ent_list)
# assure all entities are direct members TODO Can this be removed at some point?Check only? # assure all entities are direct members TODO Can this be removed at some point?Check only?
self.create_flat_list(ent_list, flat) Crawler.create_flat_list(ent_list, flat)
# TODO: can the following be removed at some point # TODO: can the following be removed at some point
for ent in flat: for ent in flat:
......
...@@ -713,3 +713,9 @@ def test_security_mode(updateCacheMock, upmock, insmock, ident): ...@@ -713,3 +713,9 @@ def test_security_mode(updateCacheMock, upmock, insmock, ident):
reset_mocks([updateCacheMock, insmock, upmock]) reset_mocks([updateCacheMock, insmock, upmock])
# restore original ident # restore original ident
ident._records = deepcopy(records_backup) ident._records = deepcopy(records_backup)
def test_create_flat_list():
a = db.Record()
a.add_property(name="a", value=a)
Crawler.create_flat_list([a], [])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment