zazuko / query-rdf-data-cube

Explore or query RDF Data Cubes with a JavaScript API, without writing SPARQL.
https://zazuko.github.io/query-rdf-data-cube/
9 stars 2 forks source link

Fetching dataCube and metadata more efficiently #37

Closed jstcki closed 4 years ago

jstcki commented 4 years ago

Follow-up on #32

Currently I'm doing something like this:

const cube = await entryPoint.dataCubeByIri(iri);

const dimensions = await cube.dimensions();

const dimensionsWithValues = await Promise.all(
  dimensions.map(async component => ({
    component,
    values: await dataSet.componentValues(component)
  }))
);

// etc. for attributes + measures

This creates lots of queries being sent, (1 dataCube + 3 component types * n component values/minmax).

It's good that these queries exist individually but in my case, I want to fetch more metadata of a cube early and use that to construct the UI.

I wonder if it would be possible/reasonable to have a cube-level method which fetches all of this metadata using less queries than I'm currently doing.

Side note: the dimension values I'm interested here are at the moment all of them, regardless of any filters applied. So maybe it would make sense to just provide them as component extraMetadata? componentValues (which respects filters) is also useful to keep but a slightly different use case.

vhf commented 4 years ago

I see your point. What do you think of #38 to solve this?

vhf commented 4 years ago

I published v0.4.0 with: