Skip to content

Commit

Permalink
feat: fix property graph query statement
Browse files Browse the repository at this point in the history
  • Loading branch information
pomelo-nwu committed Jan 2, 2025
1 parent c12c1c2 commit 31932d7
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Chart from '../ChartView/index';
import { Illustration } from '@graphscope/studio-components';
export interface IQueryPropertyStatics {
id: 'queryPropertyStatics';
query: (property: string) => Promise<{ [key: string]: any }>;
query: (label: string, property: string) => Promise<{ [key: string]: any }>;
}

interface ITableViewProps {
Expand Down Expand Up @@ -49,7 +49,7 @@ const ChartView: React.FunctionComponent<ITableViewProps> = props => {
});

try {
const data = await getService<IQueryPropertyStatics>('queryPropertyStatics')(property);
const data = await getService<IQueryPropertyStatics>('queryPropertyStatics')(label, property);
setState(preState => {
return {
...preState,
Expand Down
6 changes: 5 additions & 1 deletion packages/studio-explore/src/components/Searchbar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,11 @@ const Searchbar: React.FunctionComponent<ISearchbarProps> = props => {
/>

{state.onEnter && (
<Flex justify="center" vertical style={{ padding: '0px 12px 12px 12px' }}>
<Flex
justify="center"
vertical
style={{ padding: '0px 12px 12px 12px', overflowY: 'scroll', maxHeight: '80vh' }}
>
<>
<Divider style={{ margin: '0px' }} />
<CascaderSearch breadcrumb={breadcrumb} updateState={setState} />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import { queryStatement } from './queryStatement';
export const queryPropertyStatics = async (property: string) => {
export const queryPropertyStatics = async (label: string, property: string) => {
const match = ['year', 'month'];
if (!match.includes(property)) {
return [];
}

const data = await queryStatement(`
MATCH(a) where a.${property} IS NOT NULL
MATCH(a:${label}) where a.${property} IS NOT NULL
WITH a.${property} AS ${property}
return ${property},COUNT(${property}) as counts
`);

return data.table;
};
Original file line number Diff line number Diff line change
@@ -1,14 +1,33 @@
import { useEffect } from 'react';
import { useContext, getDataMap } from '../../';

let isCtrlPressed = false;

const useNodeClick = () => {
const { store, updateStore } = useContext();
const { emitter, data, graph } = store;

useEffect(() => {
const dataMap = getDataMap(data);

const handleKeydown = (event: KeyboardEvent) => {
if (event.key === 'Shift') {
isCtrlPressed = true;
}
};
const handleKeyup = (event: KeyboardEvent) => {
if (event.key === 'Shift') {
isCtrlPressed = false;
}
};
const applyStatus = () => {};

document.addEventListener('keydown', handleKeydown);
document.addEventListener('keyup', handleKeyup);

const handleClick = (node: any) => {
const { id } = node;
console.log(isCtrlPressed);

const {
outNeighbors = [],
Expand Down Expand Up @@ -66,6 +85,8 @@ const useNodeClick = () => {
emitter?.on('node:click', handleClick);
return () => {
emitter?.off('node:click', handleClick);
document.removeEventListener('keydown', handleKeydown);
document.removeEventListener('keyup', handleKeyup);
};
}, [emitter, data, graph]);
};
Expand Down

0 comments on commit 31932d7

Please sign in to comment.