perspective cache - basic design

This commit is contained in:
Jan Prochazka
2022-07-21 15:43:17 +02:00
parent 0f6ec420d2
commit d71294621b
10 changed files with 218 additions and 66 deletions

View File

@@ -24,7 +24,10 @@
const loadChildNodes = [];
const loadChildRows = [];
const loadProps = node.getNodeLoadProps(parentRows);
const { rows, incomplete } = await node.dataProvider.loadData(loadProps);
const { rows, incomplete } = await node.dataProvider.loadData({
...loadProps,
topCount: 100,
});
// console.log('ROWS', rows, node.isRoot);
if (node.isRoot) {

View File

@@ -22,6 +22,9 @@
import { Select } from 'dbgate-sqltree';
import ManagerInnerContainer from '../elements/ManagerInnerContainer.svelte';
import { PerspectiveDataLoader } from 'dbgate-datalib/lib/PerspectiveDataLoader';
import stableStringify from 'json-stable-stringify';
import createRef from '../utility/createRef';
import { tick } from 'svelte';
const dbg = debug('dbgate:PerspectiveView');
@@ -34,9 +37,9 @@
export let setConfig;
export let cache;
export let setCache;
let managerSize;
let nextCacheRef = createRef(null);
$: if (managerSize) setLocalStorage('perspectiveManagerWidth', managerSize);
@@ -52,8 +55,8 @@
const tableInfo = useTableInfo({ conid, database, schemaName, pureName });
const viewInfo = useViewInfo({ conid, database, schemaName, pureName });
$: loader = new PerspectiveDataLoader(apiCall, dbg);
$: dataProvider = new PerspectiveDataProvider(cache, setCache, loader);
$: dataProvider = new PerspectiveDataProvider(cache, loader);
$: loader = new PerspectiveDataLoader(apiCall);
$: root = $tableInfo
? new PerspectiveTableNode($tableInfo, $dbInfo, config, setConfig, dataProvider, { conid, database }, null)
: null;

View File

@@ -1,6 +1,9 @@
<script lang="ts">
import { PerspectiveCache } from 'dbgate-datalib';
import PerspectiveView from '../perspectives/PerspectiveView.svelte';
import usePerspectiveConfig, { usePerspectiveCache } from '../utility/usePerspectiveConfig';
import usePerspectiveConfig from '../utility/usePerspectiveConfig';
import stableStringify from 'json-stable-stringify';
export let tabid;
export let conid;
@@ -9,16 +12,7 @@
export let pureName;
const config = usePerspectiveConfig(tabid);
const cache = usePerspectiveCache();
const cache = new PerspectiveCache(stableStringify);
</script>
<PerspectiveView
{conid}
{database}
{schemaName}
{pureName}
config={$config}
setConfig={config.update}
{cache}
setCache={cache.update}
/>
<PerspectiveView {conid} {database} {schemaName} {pureName} config={$config} setConfig={config.update} {cache} />

View File

@@ -26,7 +26,9 @@ export default function usePerspectiveConfig(tabid) {
return config;
}
export function usePerspectiveCache() {
const cache = writable({});
return cache;
}
// export function usePerspectiveCache() {
// const cache = writable({
// tables: {},
// });
// return cache;
// }