cube-js / cube-js/cube

Dynamic data models with JavaScript

Open
#9,007 10 comments 0 reactions 1 assignee Claimed by @igorlukanin View on GitHub
docs question
Dominant language
Rust
Stars
20.8k
Forks
2.1k
Avg merge
1d 2h
Merged PRs (30d)
181

Description

**Describe the bug**
Each time the data model is compiled, asyncModule is called three times

**Expected behavior**
Each time the data model is compiled, asyncModule is called three times. asyncModule uses the asynchronous API to obtain the schema model, which seriously affects the API performance.

**Minimally reproducible Cube Schema**
In the following example, by introducing a logger to print information to the console, it is found that the string 'asyncModule getCubeSchema' is printed three times, which means that the asynchronous interface is requested three times.

```javascript
const {logger} = require("../src/schemaUtils")
asyncModule(async () => {
const { securityContext: { systemCode } } = COMPILE_CONTEXT
const startTime = Date.now()
const cubeList = await getCubeSchema({ systemCode })
logger('asyncModule getCubeSchema:', Date.now() - startTime)
for(let i = 0; i < cubeList.length; i++ ){
const { cubeName, ...item } = cubeList[i]
const dimensions = transformField(item.dimensions)
const measures = transformField(item.measures)
cube(cubeName, {
...item,
sql: item.sql,
dimensions,
measures
})
}
})
```

**Version:**
[e.g. 1.1.7]

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.