mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-10-29 06:32:28 +00:00
refactor(api): use executeCypher directly in buildGraph
Add public executeCypher(repoName, query) method to LocalBackend,
bypassing the callTool string dispatch and resolving the repo handle
directly. Update buildGraph in api.ts to call it instead of going
through callTool('cypher', ...) on every query.
This commit is contained in:
parent
884b6265cf
commit
aa12d17504
2 changed files with 10 additions and 5 deletions
|
|
@ -636,6 +636,11 @@ export class LocalBackend {
|
|||
}
|
||||
}
|
||||
|
||||
async executeCypher(repoName: string, query: string): Promise<any> {
|
||||
const repo = await this.resolveRepo(repoName);
|
||||
return this.cypher(repo, { query });
|
||||
}
|
||||
|
||||
private async cypher(repo: RepoHandle, params: { query: string }): Promise<any> {
|
||||
await this.ensureInitialized(repo.id);
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ const buildGraph = async (
|
|||
query = `MATCH (n:${table}) RETURN n.id AS id, n.name AS name, n.filePath AS filePath, n.startLine AS startLine, n.endLine AS endLine, n.content AS content`;
|
||||
}
|
||||
|
||||
const result = await backend.callTool('cypher', { repo: repoName, query });
|
||||
const result = await backend.executeCypher(repoName, query);
|
||||
// cypher returns the rows directly (array), or { error } on failure
|
||||
const rows = Array.isArray(result) ? result : [];
|
||||
|
||||
|
|
@ -71,10 +71,10 @@ const buildGraph = async (
|
|||
|
||||
const relationships: GraphRelationship[] = [];
|
||||
try {
|
||||
const relResult = await backend.callTool('cypher', {
|
||||
repo: repoName,
|
||||
query: `MATCH (a)-[r:CodeRelation]->(b) RETURN a.id AS sourceId, b.id AS targetId, r.type AS type, r.confidence AS confidence, r.reason AS reason, r.step AS step`,
|
||||
});
|
||||
const relResult = await backend.executeCypher(
|
||||
repoName,
|
||||
`MATCH (a)-[r:CodeRelation]->(b) RETURN a.id AS sourceId, b.id AS targetId, r.type AS type, r.confidence AS confidence, r.reason AS reason, r.step AS step`,
|
||||
);
|
||||
const relRows = Array.isArray(relResult) ? relResult : [];
|
||||
|
||||
for (const row of relRows) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue