Skip to content

Dynamic data models with JavaScript #9007

Open
@tiger-feng

Description

@tiger-feng

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.

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]

Metadata

Metadata

Assignees

Labels

docsIssues that require a documentation improvementquestionThe issue is a question. Please use Stack Overflow for questions.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions