ontoportal-lirmm / ontologies_api_ruby_client

A Ruby client for accessing NCBO's hypermedia api
Other
0 stars 1 forks source link

Fix: optimize the way we do our calls to the API #14

Closed syphax-bouazzouni closed 8 months ago

syphax-bouazzouni commented 8 months ago

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 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:

In the future, we can remove this call.

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}

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)

Changes