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

resource-instance-select vm looks up tile's related resources one at a time #11577

Open
whatisgalen opened this issue Oct 26, 2024 · 0 comments

Comments

@whatisgalen
Copy link
Member

whatisgalen commented Oct 26, 2024

A resource-instance-list datatype node can have references to N other resource-instances. Once that list gets large, the report slows down considerably.

in the resource-instance-select viewmodel, there's some logic executed for each related resource instance in the tile value:

var updateNameAndOntologyClass = function(values) {
                var names = [];
                var value = ko.unwrap(values);
                if (!self.multiple && value && !Array.isArray(value)) {
                    value = [value];
                }
                if(!!value) {
                    value.forEach(function(val) {
                        if (val) {
                            if(!val.resourceName) {
                                Object.defineProperty(val, 'resourceName', {value: ko.observable()});
                            }
                            if(!val.ontologyClass) {
                                Object.defineProperty(val, 'ontologyClass', {value:ko.observable()});
                            }
                            if(!val.iconClass) {
                                Object.defineProperty(val, 'iconClass', {value: ko.observable()});
                            }
                            resourceUtils.lookupResourceInstanceData(ko.unwrap(val.resourceId))
                                .then(function(resourceInstance) {
                                    if (resourceInstance) {
                                        names.push(resourceInstance["_source"].displayname);
                                        self.displayValue(names.join(', '));
                                        val.resourceName(resourceInstance["_source"].displayname);
                                        val?.iconClass(self.graphLookup[resourceInstance["_source"].graph_id]?.iconclass || 'fa fa-question');
                                        val.ontologyClass(resourceInstance["_source"].root_ontology_class);
                                    }
                                });
                        }
                    });
                }
            };

... which is a problem, because resourceUtils.lookupResourceInstanceData( executes a single search query each time it's called. For tiles where there might be 100 related resources, this is a major performance hit.

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

No branches or pull requests

1 participant