Refactor: use reduce for collecting overviews metadata
This commit is contained in:
parent
57cba3d511
commit
ecbae52abe
@ -31,18 +31,17 @@ OverviewsMetadataApi.prototype.getOverviewsMetadata = function (username, sql, c
|
|||||||
callback(err);
|
callback(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var metadata = {};
|
var metadata = rows.reduce(function(metadata, row){
|
||||||
rows.forEach(function(row) {
|
|
||||||
var table = row.base_table;
|
var table = row.base_table;
|
||||||
var schema = row._cdb_schema_name;
|
var schema = row._cdb_schema_name;
|
||||||
var table_metadata = metadata[table];
|
var table_metadata = metadata[table];
|
||||||
if ( !table_metadata ) {
|
if ( !table_metadata ) {
|
||||||
table_metadata = metadata[table] = {};
|
table_metadata = metadata[table] = {};
|
||||||
}
|
}
|
||||||
table_metadata[row.z] = { table: row.overview_table };
|
table_metadata[row.z] = { table: row.overview_table };
|
||||||
table_metadata.schema = schema;
|
table_metadata.schema = schema;
|
||||||
});
|
return metadata;
|
||||||
|
}, {});
|
||||||
return callback(null, metadata);
|
return callback(null, metadata);
|
||||||
});
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user