Skip to content

Commit

Permalink
fix: Funnel step names cannot contain spaces
Browse files Browse the repository at this point in the history
Fixes #359
  • Loading branch information
paveltiunov committed Feb 4, 2020
1 parent f0844bb commit aff1891
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
8 changes: 6 additions & 2 deletions packages/cubejs-schema-compiler/extensions/Funnels.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,15 @@ ${eventJoin.join("\nLEFT JOIN\n")}
}

eventsTableName(step) {
return `${inflection.underscore(step.name)}_events`;
return `${this.inflect(step)}_events`;
}

stepUserIdColumnName(step) {
return `${inflection.underscore(step.name)}_user_id`;
return `${this.inflect(step)}_user_id`;
}

inflect(step) {
return inflection.underscore(inflection.camelize(step.name.replace(/[^A-Za-z0-9]+/g, '_')));
}

stepSegmentSelect(funnelDefinition, step) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class ScaffoldingTemplate {
}

memberName(member) {
return inflection.camelize(member.title.replace(/\s+|\./g, '_').toLowerCase(), true);
return inflection.camelize(member.title.replace(/[^A-Za-z0-9]+/g, '_').toLowerCase(), true);
}

renderFile(fileDescriptor) {
Expand Down
8 changes: 6 additions & 2 deletions packages/cubejs-schema-compiler/test/ExtensionsTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ describe('Extensions', () => {
},
steps: [
{
name: 'application_installed',
name: 'Application Installed',
eventsTable: {
sql: 'application_installed'
}
},
{
name: 'application_opened',
name: 'ApplicationOpened',
eventsView: {
sql: 'application_opened'
},
Expand Down Expand Up @@ -79,6 +79,10 @@ describe('Extensions', () => {
});

console.log(query.buildSqlAndParams()[0]);

query.buildSqlAndParams()[0].should.match(/application_installed_events/);
query.buildSqlAndParams()[0].should.match(/application_opened_events/);
query.buildSqlAndParams()[0].should.match(/user_training_finish_first_events/);
});

return result;
Expand Down

0 comments on commit aff1891

Please sign in to comment.