Skip to content
Snippets Groups Projects
Commit 60f3fb41 authored by Leonardo's avatar Leonardo
Browse files

feat(schema): adding schema stats to eventBus

parent 9ce7fed0
No related branches found
Tags v1.66.0
No related merge requests found
Pipeline #137625 failed
......@@ -13,6 +13,7 @@ import {
wsSchemaRequest,
wsSchemaSubscription,
useQuerybuilderAttributesShown,
wsSchemaStatsRequest,
} from '@graphpolaris/shared/lib/data-access';
import { Broker, wsQuerySubscription, wsQueryTranslationSubscription } from '@graphpolaris/shared/lib/data-access/broker';
import { addInfo } from '@graphpolaris/shared/lib/data-access/store/configSlice';
......@@ -207,6 +208,7 @@ export const EventBus = (props: { onRunQuery: Function; onAuthorized: Function }
// New active database
if (session.currentSaveState && session.currentSaveState !== nilUUID) {
wsSchemaRequest(session.currentSaveState);
wsSchemaStatsRequest(session.currentSaveState);
wsSelectState(session.currentSaveState);
loadSaveState(session.currentSaveState, session.saveStates);
}
......
// All database related API calls
import { SchemaFromBackend } from '../../schema';
import { SchemaFromBackend, SchemaStatsFromBackend } from '../../schema';
import { Broker } from './broker';
export function wsSchemaRequest(saveStateID: string) {
......@@ -13,6 +13,7 @@ export function wsSchemaRequest(saveStateID: string) {
},
});
}
type SchemaResponse = (data: SchemaFromBackend) => void;
export function wsSchemaSubscription(callback: SchemaResponse) {
const id = Broker.instance().subscribe(callback, 'schema_result');
......@@ -20,3 +21,22 @@ export function wsSchemaSubscription(callback: SchemaResponse) {
Broker.instance().unSubscribe('schema_result', id);
};
}
export function wsSchemaStatsRequest(saveStateID: string) {
Broker.instance().sendMessage({
key: 'schema',
subKey: 'getSchemaStats',
body: {
cached: false,
saveStateID: saveStateID,
},
});
}
type SchemaStatsResponse = (data: SchemaStatsFromBackend) => void;
export function wsSchemaStatsSubscription(callback: SchemaStatsResponse) {
const id = Broker.instance().subscribe(callback, 'schema_stats_result');
return () => {
Broker.instance().unSubscribe('schema_stats_result', id);
};
}
......@@ -6,6 +6,18 @@ export type SchemaFromBackend = {
nodes: SchemaNode[];
};
export type SchemaStatsFromBackend = {
edgeStats: {
type: string;
count: number;
}[];
nodeStats: {
key: string;
labels: string[];
count: number;
}[];
};
export type SchemaAttributeTypes = 'string' | 'float' | 'int' | 'bool' | 'date' | 'time' | 'datetime' | 'duration';
export type DimensionType = 'categorical' | 'numerical' | 'temporal' | 'spatial';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment