Skip to content

Commit

Permalink
fix: Don't fetch schema twice when generating in Playground. Big sche…
Browse files Browse the repository at this point in the history
…mas take a lot of time to fetch.
  • Loading branch information
paveltiunov committed Feb 6, 2020
1 parent f1b54be commit 3eeb73a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions packages/cubejs-playground/src/SchemaPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,18 @@ class SchemaPage extends Component {
}

async generateSchema() {
const { checkedKeys } = this.state;
const { checkedKeys, tablesSchema } = this.state;
const { history } = this.props;
playgroundAction('Generate Schema');
const res = await fetch('/playground/generate-schema', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ tables: checkedKeys.filter(k => k.split('.').length === 2) })
body: JSON.stringify({
tables: checkedKeys.filter(k => k.split('.').length === 2),
tablesSchema
})
});
if (res.status === 200) {
playgroundAction('Generate Schema Success');
Expand Down
2 changes: 1 addition & 1 deletion packages/cubejs-server-core/core/DevServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class DevServer {
app.post('/playground/generate-schema', catchErrors(async (req, res) => {
this.cubejsServer.event('Dev Server Generate Schema');
const driver = await this.cubejsServer.getDriver();
const tablesSchema = await driver.tablesSchema();
const tablesSchema = req.body.tablesSchema || (await driver.tablesSchema());

const ScaffoldingTemplate = require('@cubejs-backend/schema-compiler/scaffolding/ScaffoldingTemplate');
const scaffoldingTemplate = new ScaffoldingTemplate(tablesSchema, driver);
Expand Down

0 comments on commit 3eeb73a

Please sign in to comment.