Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing nodes in __get_nodegroup_tree #10889

Open
jacobtylerwalls opened this issue May 8, 2024 · 0 comments
Open

Missing nodes in __get_nodegroup_tree #10889

jacobtylerwalls opened this issue May 8, 2024 · 0 comments

Comments

@jacobtylerwalls
Copy link
Member

jacobtylerwalls commented May 8, 2024

The db functions __get_nodegroup_tree or __get_nodegroup_tree_by_graph appear to miss child nodes, unless I'm misunderstanding how they work.

With this setup:

from pathlib import Path

from django.conf import settings
from django.core.management import call_command

from arches.app.utils.betterJSONSerializer import JSONDeserializer
from arches.app.utils.data_management.resource_graphs.importer import import_graph as ResourceGraphImporter
from arches.app.utils.skos import SKOSReader

ROOT_DIR = settings.ROOT_DIR
JSON_LD_FIXTURE = Path(ROOT_DIR).parent / "tests" / "fixtures" / "jsonld_base"
ONTOLOGY_PATH = Path(ROOT_DIR).parent / "tests" / "fixtures" / "ontologies" / "cidoc_crm"
call_command("load_ontology", source=ONTOLOGY_PATH, verbosity=0)

skos = SKOSReader()
rdf = skos.read_file(str(JSON_LD_FIXTURE / "rdm" / "jsonld_test_thesaurus.xml"))
ret = skos.save_concepts_from_skos(rdf)

skos = SKOSReader()
rdf = skos.read_file(str(JSON_LD_FIXTURE / "rdm" / "jsonld_test_collections.xml"))
ret = skos.save_concepts_from_skos(rdf)

with open(JSON_LD_FIXTURE / "models" / "test_2_complex_object.json", "r") as f:
    archesfile2 = JSONDeserializer().deserialize(f)

ResourceGraphImporter(archesfile2['graph'])
SELECT
	COUNT(nodegroupid)
FROM
	nodes
WHERE
	graphid = 'ee72fb1e-fa6c-11e9-b369-3af9d3b32b71';

-- Result: 13

SELECT
	COUNT(nodegroupid)
FROM
	__get_nodegroup_tree_by_graph ('ee72fb1e-fa6c-11e9-b369-3af9d3b32b71');

-- Result: 9, expected 12 (seems okay to omit the top node)

-- Next query shows what's missing: just the child nodes
SELECT
	*
FROM
	nodes
WHERE
	graphid = UUID('ee72fb1e-fa6c-11e9-b369-3af9d3b32b71')
	AND alias NOT IN(
		SELECT
			alias FROM __get_nodegroup_tree_by_graph (UUID('ee72fb1e-fa6c-11e9-b369-3af9d3b32b71')));

Noticed while dev'ing #10798

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

1 participant