Skip to content

Commit

Permalink
Make frontend and runner implementation the same
Browse files Browse the repository at this point in the history
  • Loading branch information
darunrs committed Aug 29, 2023
1 parent f3232df commit 6ec6489
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions frontend/src/utils/indexerRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,26 @@ export default class IndexerRunner {
});
}

async executeIndexerFunction(height, blockDetails, indexingCode, schema, schemaName) {
let innerCode = indexingCode.match(/getBlock\s*\([^)]*\)\s*{([\s\S]*)}/)[1];
getTableNames (schema) {
const tableRegex = /CREATE TABLE\s+(?:IF NOT EXISTS)?\s+"?(.+?)"?\s*\(/g;
const tableNames = Array.from(schema.matchAll(tableRegex), match => {
let tableName;
if (match[1].includes(".")) { // If expression after create has schemaName.tableName, return only tableName
tableName = match[1].split(".")[1];
if (match[1].includes('.')) { // If expression after create has schemaName.tableName, return only tableName
tableName = match[1].split('.')[1];
tableName = tableName.startsWith('"') ? tableName.substring(1) : tableName;
} else {
tableName = match[1];
}
return /^\w+$/.test(tableName) ? tableName : `"${tableName}"`; // If table name has special characters, it must be inside double quotes
});
this.validateTableNames(tableNames);
console.log('Retrieved the following table names from schema: ', tableNames);
return tableNames;
}

async executeIndexerFunction(height, blockDetails, indexingCode, schema, schemaName) {
let innerCode = indexingCode.match(/getBlock\s*\([^)]*\)\s*{([\s\S]*)}/)[1];
const tableNames = this.getTableNames(schema);

if (blockDetails) {
const block = Block.fromStreamerMessage(blockDetails);
Expand Down

0 comments on commit 6ec6489

Please sign in to comment.