mirror of
https://github.com/getredash/redash.git
synced 2025-12-19 17:37:19 -05:00
* Prettier all the JS files * Add GitHub Action to autoformat code pushed to master * Fix eslint violation due to formatting. * Remove GitHub actions for styling * Add restyled.io config
51 lines
1.0 KiB
JavaScript
51 lines
1.0 KiB
JavaScript
import { map } from "lodash";
|
|
|
|
function buildTableColumnKeywords(table) {
|
|
const keywords = [];
|
|
table.columns.forEach(column => {
|
|
keywords.push({
|
|
caption: column,
|
|
name: `${table.name}.${column}`,
|
|
value: `${table.name}.${column}`,
|
|
score: 100,
|
|
meta: "Column",
|
|
className: "completion",
|
|
});
|
|
});
|
|
return keywords;
|
|
}
|
|
|
|
function buildKeywordsFromSchema(schema) {
|
|
const tableKeywords = [];
|
|
const columnKeywords = {};
|
|
const tableColumnKeywords = {};
|
|
|
|
schema.forEach(table => {
|
|
tableKeywords.push({
|
|
name: table.name,
|
|
value: table.name,
|
|
score: 100,
|
|
meta: "Table",
|
|
});
|
|
tableColumnKeywords[table.name] = buildTableColumnKeywords(table);
|
|
table.columns.forEach(c => {
|
|
columnKeywords[c] = "Column";
|
|
});
|
|
});
|
|
|
|
return {
|
|
table: tableKeywords,
|
|
column: map(columnKeywords, (v, k) => ({
|
|
name: k,
|
|
value: k,
|
|
score: 50,
|
|
meta: v,
|
|
})),
|
|
tableColumn: tableColumnKeywords,
|
|
};
|
|
}
|
|
|
|
export default {
|
|
buildKeywordsFromSchema,
|
|
};
|