Skip to content
Snippets Groups Projects
Commit 9ecb7248 authored by Leonardo's avatar Leonardo
Browse files

feat: differentiation

parent 4766c036
No related branches found
No related tags found
No related merge requests found
Pipeline #145213 passed
import { createSlice, PayloadAction } from '@reduxjs/toolkit';
import type { AppDispatch, RootState } from './store';
import { GraphQueryResultFromBackend, GraphStatistics, NodeAttributes, QueryStatusResult } from 'ts-common';
import {
CountQueryResultFromBackend,
GraphQueryResultFromBackend,
GraphQueryResultMetaFromBackend,
GraphStatistics,
NodeAttributes,
QueryStatusResult,
} from 'ts-common';
export type UniqueEdge = {
attributes: NodeAttributes;
......@@ -10,17 +17,21 @@ export type UniqueEdge = {
};
// Define a type for the slice state
export type GraphQueryResult = GraphQueryResultFromBackend & {
export type GraphQueryResult = GraphQueryResultMetaFromBackend & {
queryingBackend: boolean;
metaData?: GraphStatistics;
};
// Define the initial state using that type
export const initialState: GraphQueryResult = {
metaData: undefined,
metaData: {
nodes: { count: 0, labels: [], types: {} },
edges: { count: 0, labels: [], types: {} },
topological: { density: 0, self_loops: 0 },
},
nodes: [],
edges: [],
queryingBackend: false,
nodeCounts: {},
};
export const graphQueryResultSlice = createSlice({
......@@ -32,13 +43,19 @@ export const graphQueryResultSlice = createSlice({
state.metaData = action.payload.result.payload.metaData;
state.nodes = action.payload.result.payload.nodes;
state.edges = action.payload.result.payload.edges;
state.nodeCounts = action.payload.result.payload.nodeCounts;
state.queryingBackend = false;
},
resetGraphQueryResults: state => {
// Assign new state
state.metaData = undefined;
state.metaData = {
nodes: { count: 0, labels: [], types: {} },
edges: { count: 0, labels: [], types: {} },
topological: { density: 0, self_loops: 0 },
};
state.nodes = [];
state.edges = [];
state.nodeCounts = {};
state.queryingBackend = false;
},
queryingBackend: (state, action: PayloadAction<boolean | undefined>) => {
......
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