Dynamic data models with JavaScript
- 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
Assessment
This issue has not been assessed yet.