Skip to content

Commit

Permalink
fix for slow reports, re #11748 (#11749)
Browse files Browse the repository at this point in the history
fix for slow reports, re #11748
  • Loading branch information
apeters authored Jan 24, 2025
1 parent 4b44911 commit 9451385
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
16 changes: 9 additions & 7 deletions arches/app/models/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion arches/app/views/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 3 additions & 1 deletion arches/app/views/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down Expand Up @@ -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(
Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions releases/7.6.6.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 9451385

Please sign in to comment.