From 94513851f9c771a9002c6c2df15044ae2883568e Mon Sep 17 00:00:00 2001 From: Alexei Peters <apeters@fargeo.com> Date: Fri, 24 Jan 2025 15:09:39 -0800 Subject: [PATCH 1/2] fix for slow reports, re #11748 (#11749) fix for slow reports, re #11748 --- arches/app/models/resource.py | 16 +++++++++------- arches/app/views/api.py | 4 +++- arches/app/views/resource.py | 4 +++- releases/7.6.6.md | 1 + 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/arches/app/models/resource.py b/arches/app/models/resource.py index 54ceb3b5445..b7ddf797be4 100644 --- a/arches/app/models/resource.py +++ b/arches/app/models/resource.py @@ -770,6 +770,7 @@ def get_related_resources( user=None, resourceinstance_graphid=None, graphs=None, + include_rr_count=True, ): """ Returns an object that lists the related resources, the relationship types, and a reference to the current resource @@ -928,13 +929,14 @@ def get_relations( if related_resources: for resource in related_resources["docs"]: if resource["found"]: - rel_count = get_relations( - resourceinstanceid=resource["_id"], - start=0, - limit=0, - count_only=True, - ) - resource["_source"]["total_relations"] = rel_count + if include_rr_count: + rel_count = get_relations( + resourceinstanceid=resource["_id"], + start=0, + limit=0, + count_only=True, + ) + resource["_source"]["total_relations"] = rel_count for descriptor_type in ("displaydescription", "displayname"): descriptor = get_localized_descriptor( resource, descriptor_type diff --git a/arches/app/views/api.py b/arches/app/views/api.py index 7af6bc9e2d2..5fd27ea8482 100644 --- a/arches/app/views/api.py +++ b/arches/app/views/api.py @@ -1299,7 +1299,9 @@ def get(self, request, resourceid): get_params.update({"paginate": "false"}) request.GET = get_params - related_resources_response = RelatedResourcesView().get(request, resourceid) + related_resources_response = RelatedResourcesView().get( + request, resourceid, include_rr_count=False + ) related_resources = json.loads(related_resources_response.content) related_resources_summary = self._generate_related_resources_summary( diff --git a/arches/app/views/resource.py b/arches/app/views/resource.py index 412704796b6..719e445eaf9 100644 --- a/arches/app/views/resource.py +++ b/arches/app/views/resource.py @@ -1008,7 +1008,7 @@ def parse_relationshiptype_label(relationship): return ret - def get(self, request, resourceid=None): + def get(self, request, resourceid=None, include_rr_count=True): ret = {} if self.action == "get_candidates": @@ -1055,6 +1055,7 @@ def get(self, request, resourceid=None): user=request.user, resourceinstance_graphid=resourceinstance_graphid, graphs=self.graphs, + include_rr_count=include_rr_count, ) ret = self.paginate_related_resources( @@ -1066,6 +1067,7 @@ def get(self, request, resourceid=None): user=request.user, resourceinstance_graphid=resourceinstance_graphid, graphs=self.graphs, + include_rr_count=include_rr_count, ) return JSONResponse(ret) diff --git a/releases/7.6.6.md b/releases/7.6.6.md index a71a7dc20cd..82df124b2a2 100644 --- a/releases/7.6.6.md +++ b/releases/7.6.6.md @@ -3,6 +3,7 @@ ### Bug Fixes and Enhancements - Fix inability to remove a second parent from a concept [#11742](https://github.com/archesproject/arches/pull/11742) +- Fix slow reports when used on systems with many related resources [#11748](https://github.com/archesproject/arches/pull/11748) ### Dependency changes: From fa10839ec9f992548ee5794405eb69dd26b057dc Mon Sep 17 00:00:00 2001 From: Cyrus Hiatt <chiatt@fargeo.com> Date: Fri, 24 Jan 2025 15:37:41 -0800 Subject: [PATCH 2/2] Add changelog entry for #11744 (#11750) --- releases/7.6.6.md | 1 + 1 file changed, 1 insertion(+) diff --git a/releases/7.6.6.md b/releases/7.6.6.md index 82df124b2a2..0fea74eb8b7 100644 --- a/releases/7.6.6.md +++ b/releases/7.6.6.md @@ -4,6 +4,7 @@ - Fix inability to remove a second parent from a concept [#11742](https://github.com/archesproject/arches/pull/11742) - Fix slow reports when used on systems with many related resources [#11748](https://github.com/archesproject/arches/pull/11748) +- Reimplement superuser bypass of nodegroup permission check [#11744](https://github.com/archesproject/arches/pull/11744) ### Dependency changes: