This repository is responsible for translating our front Ruby code to the corresponding HTTP call to the API, e.g Ontology.all we will be translated to /ontologies and Ontology.get(id) to /ontologies/{id}
Issue
Some important optimization can be easily done, below is a list of the issues that this PR is resolving:
Fetching top-level links on each request
For any request done to the API we do at list 2, e.g Ontology.all
Instead of just https://data.agroportal.lirmm.fr/ontologies, we do the first call to get the links part of https://data.agroportal.lirmm.fr and to know the endpoint of the resource, for example for Ontology it would be https://data.agroportal.lirmm.fr/ontologies.
The fix here was to save the response returned by https://data.agroportal.lirmm.fr the first in a variable so that we do call each time.
In the future, we can remove this call.
Using .find() instead systematicity .get()
This one is the one really demanding in response time, which when we do Ontology.find(id) to go to /ontologies/{id} and return the JSON-LD of an ontology. In reality, was doing /ontologies, fetching all ontologies, and then filtering the result by the id provided.
The fix here is to deprecate .find() method (and remove it in the future), and replace it with .get() which does the direct call Ontology.find(id) => https://data.agroportal.lirmm.fr/ontologies/{id}
Refresh caching on each update
Each time we do a save or an update we refresh the cache, of the current resource updated/saved, all its brothers and all the ontologies, and all the submissions and all the users.
So for example if update/save an Ontology 1, I refresh its cache (which is good), but also all the ontologies, and all the ontologies a second time, and all the submissions and all the users caches. Resulting in these calls on each update/save
Getting: https://data.agroportal.lirmm.fr/ontologies/WHEATPHENOTYPE (0.2069408730021678s)
Update (Put): https://data.agroportal.lirmm.fr/ontologies/WHEATPHENOTYPE
Getting: https://data.agroportal.lirmm.fr/ontologies/WHEATPHENOTYPE with invalidate cache header (0.2069408730021678s)
Getting: https://data.agroportal.lirmm.fr/ontologies with invalidate cache header (1.135303320013918s)
Getting: https://data.agroportal.lirmm.fr/submissions with invalidate cache header (1.0787174180150032s)
Getting: https://data.agroportal.lirmm.fr/users with invalidate cache header (0.3540415579918772s)
Context
This repository is responsible for translating our front Ruby code to the corresponding HTTP call to the API, e.g
Ontology.all
we will be translated to/ontologies
andOntology.get(id)
to/ontologies/{id}
Issue
Some important optimization can be easily done, below is a list of the issues that this PR is resolving:
Ontology.all
Instead of just
https://data.agroportal.lirmm.fr/ontologies
, we do the first call to get thelinks
part ofhttps://data.agroportal.lirmm.fr
and to know the endpoint of the resource, for example forOntology
it would behttps://data.agroportal.lirmm.fr/ontologies
. The fix here was to save the response returned byhttps://data.agroportal.lirmm.fr
the first in a variable so that we do call each time.In the future, we can remove this call.
.find()
instead systematicity.get()
This one is the one really demanding in response time, which when we doOntology.find(id)
to go to/ontologies/{id}
and return the JSON-LD of an ontology. In reality, was doing/ontologies
, fetching all ontologies, and then filtering the result by theid
provided.The fix here is to deprecate
.find()
method (and remove it in the future), and replace it with.get()
which does the direct callOntology.find(id) => https://data.agroportal.lirmm.fr/ontologies/{id}
Each time we do a save or an update we refresh the cache, of the current resource updated/saved, all its brothers and all the ontologies, and all the submissions and all the users.
So for example if update/save an
Ontology 1
, I refresh its cache (which is good), but also all the ontologies, and all the ontologies a second time, and all the submissions and all the users caches. Resulting in these calls on each update/saveChanges