Skip to content

Commit b7fbdbf

Browse files
committed
fix: fixed nodes and edges count issue
1 parent 7e99be7 commit b7fbdbf

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

backend/app/database/falkor/code-graph-backend/api/index.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
""" Main API module for CodeGraph. """
2+
import logging
23
import os
34
from pathlib import Path
45
from functools import wraps
@@ -18,7 +19,6 @@
1819
load_dotenv()
1920

2021
# Configure the logger
21-
import logging
2222
logging.basicConfig(level=logging.DEBUG,
2323
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
2424
logger = logging.getLogger(__name__)
@@ -38,6 +38,7 @@ def decorated_function(*args, **kwargs):
3838
return f(*args, **kwargs)
3939
return decorated_function
4040

41+
4142
app = Flask(__name__)
4243

4344
def public_access(f):
@@ -109,7 +110,7 @@ def get_neighbors():
109110
data = request.get_json()
110111

111112
# Get query parameters
112-
repo = data.get('repo')
113+
repo = data.get('repo')
113114
node_ids = data.get('node_ids')
114115

115116
# Validate 'repo' parameter
@@ -298,7 +299,7 @@ def find_paths():
298299
paths = g.find_paths(src, dest)
299300

300301
# Create and return a successful response
301-
response = { 'status': 'success', 'paths': paths }
302+
response = {'status': 'success', 'paths': paths}
302303

303304
return jsonify(response), 200
304305

@@ -323,7 +324,7 @@ def chat():
323324
answer = ask(repo, msg)
324325

325326
# Create and return a successful response
326-
response = { 'status': 'success', 'response': answer }
327+
response = {'status': 'success', 'response': answer}
327328

328329
return jsonify(response), 200
329330

@@ -346,8 +347,8 @@ def analyze_folder():
346347
data = request.get_json()
347348

348349
# Get query parameters
349-
path = data.get('path')
350-
ignore = data.get('ignore', [])
350+
path = data.get('path')
351+
ignore = data.get('ignore', [])
351352

352353
# Validate input parameters
353354
if not path:
@@ -375,9 +376,9 @@ def analyze_folder():
375376

376377
# Return response
377378
response = {
378-
'status': 'success',
379-
'project': proj_name
380-
}
379+
'status': 'success',
380+
'project': proj_name
381+
}
381382
return jsonify(response), 200
382383

383384
@app.route('/analyze_repo', methods=['POST'])
@@ -409,9 +410,12 @@ def analyze_repo():
409410
proj.analyze_sources(ignore)
410411
proj.process_git_history(ignore)
411412

412-
# Create a response
413+
stats = proj.graph.stats()
414+
413415
response = {
414416
'status': 'success',
417+
'node_count': stats.get('node_count', 0),
418+
'edge_count': stats.get('edge_count', 0)
415419
}
416420

417421
return jsonify(response), 200
@@ -472,7 +476,7 @@ def list_commits():
472476
# Validate the presence of the 'repo' parameter
473477
repo = data.get('repo')
474478
if repo is None:
475-
return jsonify({'status': f'Missing mandatory parameter "repo"'}), 400
479+
return jsonify({'status': 'Missing mandatory parameter "repo"'}), 400
476480

477481
# Initialize GitGraph object to interact with the repository
478482
git_graph = GitGraph(git_utils.GitRepoName(repo))
@@ -486,4 +490,4 @@ def list_commits():
486490
'commits': commits
487491
}
488492

489-
return jsonify(response), 200
493+
return jsonify(response), 200

backend/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313

1414
MODEL_NAME = os.getenv("EMBEDDING_MODEL", "BAAI/bge-small-en-v1.5")
1515
MAX_BATCH_SIZE = int(os.getenv("EMBEDDING_MAX_BATCH_SIZE", "32"))
16-
EMBEDDING_DEVICE = os.getenv("EMBEDDING_DEVICE", "cpu")
16+
EMBEDDING_DEVICE = os.getenv("EMBEDDING_DEVICE", "cpu")

0 commit comments

Comments
 (0)