wip fix
This commit is contained in:
parent
dbf95954d5
commit
6dcf23ad74
File diff suppressed because one or more lines are too long
|
|
@ -108,29 +108,31 @@ const cachedQueryResult: Record<
|
||||||
> = {};
|
> = {};
|
||||||
|
|
||||||
export const fetchSendDb = async (params: any, dburl: string) => {
|
export const fetchSendDb = async (params: any, dburl: string) => {
|
||||||
const base = new URL(dburl);
|
try {
|
||||||
base.pathname = `/_dbs`;
|
const base = new URL(dburl);
|
||||||
if (params.table) {
|
base.pathname = `/_dbs`;
|
||||||
base.pathname += `/${params.table}`;
|
if (params.table) {
|
||||||
}
|
base.pathname += `/${params.table}`;
|
||||||
const url = base.toString();
|
}
|
||||||
|
const url = base.toString();
|
||||||
|
|
||||||
const hsum = hash_sum(params);
|
const hsum = hash_sum(params);
|
||||||
const cached = cachedQueryResult[hsum];
|
const cached = cachedQueryResult[hsum];
|
||||||
|
|
||||||
if (!cached || (cached && Date.now() - cached.timestamp > 1000)) {
|
if (!cached || (cached && Date.now() - cached.timestamp > 1000)) {
|
||||||
cachedQueryResult[hsum] = {
|
cachedQueryResult[hsum] = {
|
||||||
timestamp: Date.now(),
|
timestamp: Date.now(),
|
||||||
promise: fetchViaProxy(url, params, {
|
promise: fetchViaProxy(url, params, {
|
||||||
"content-type": "application/json",
|
"content-type": "application/json",
|
||||||
}),
|
}),
|
||||||
result: null,
|
result: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
const result = await cachedQueryResult[hsum].promise;
|
const result = await cachedQueryResult[hsum].promise;
|
||||||
cachedQueryResult[hsum].result = result;
|
cachedQueryResult[hsum].result = result;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
return await cached.promise;
|
return await cached.promise;
|
||||||
|
} catch (e) {}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue