mirror of
https://github.com/getredash/redash.git
synced 2026-03-21 07:00:07 -04:00
* Add refresh button in the bottom * Add caching * Drop allSettled * Simplify refresh button * Update error to return 500 * Load tables before loading columns * Don't mutate schema * Reset db name and schemas when changing data source * Load both tables and columns * Return error with code 200 * Code review updates * Add expiration time to the cache Keys * Back with RQ
44 lines
1.3 KiB
JavaScript
44 lines
1.3 KiB
JavaScript
import { has } from "lodash";
|
|
import { axios } from "@/services/axios";
|
|
import DataSource from "@/services/data-source";
|
|
import { fetchDataFromJob } from "@/services/query-result";
|
|
|
|
function fetchDataFromJobOrReturnData(data) {
|
|
return has(data, "job.id") ? fetchDataFromJob(data.job.id, 1000) : data;
|
|
}
|
|
|
|
function rejectErrorResponse(data) {
|
|
return has(data, "error") ? Promise.reject(new Error(data.error.message)) : data;
|
|
}
|
|
|
|
export default {
|
|
...DataSource,
|
|
getDatabases: ({ id }, refresh = false) => {
|
|
const params = {};
|
|
|
|
if (refresh) {
|
|
params.refresh = true;
|
|
}
|
|
return axios
|
|
.get(`api/databricks/databases/${id}`, { params })
|
|
.then(fetchDataFromJobOrReturnData)
|
|
.then(rejectErrorResponse);
|
|
},
|
|
getDatabaseTables: (data, databaseName, refresh = false) => {
|
|
const params = {};
|
|
|
|
if (refresh) {
|
|
params.refresh = true;
|
|
}
|
|
return axios
|
|
.get(`api/databricks/databases/${data.id}/${databaseName}/tables`, { params })
|
|
.then(fetchDataFromJobOrReturnData)
|
|
.then(rejectErrorResponse);
|
|
},
|
|
getTableColumns: (data, databaseName, tableName) =>
|
|
axios
|
|
.get(`api/databricks/databases/${data.id}/${databaseName}/columns/${tableName}`)
|
|
.then(fetchDataFromJobOrReturnData)
|
|
.then(rejectErrorResponse),
|
|
};
|