@@ -79,31 +79,28 @@ def graph_entities():
79
79
return jsonify ({"status" : "Internal server error" }), 500
80
80
81
81
82
- @app .route ('/get_neighbors' , methods = ['POST ' ])
82
+ @app .route ('/get_neighbors' , methods = ['GET ' ])
83
83
@token_required # Apply token authentication decorator
84
84
def get_neighbors ():
85
85
"""
86
- Endpoint to get neighbors of a nodes list in the graph.
87
- Expects 'repo' and 'node_ids ' as body parameters.
86
+ Endpoint to get neighbors of a specific node in the graph.
87
+ Expects 'repo' and 'node_id ' as query parameters.
88
88
89
89
Returns:
90
90
JSON response containing neighbors or error messages.
91
91
"""
92
92
93
- # Get JSON data from the request
94
- data = request .get_json ()
95
-
96
93
# Get query parameters
97
- repo = data .get ('repo' )
98
- node_ids = data . get ('node_ids ' )
94
+ repo = request . args .get ('repo' )
95
+ node_id = request . args . get ('node_id ' )
99
96
100
97
# Validate 'repo' parameter
101
98
if not repo :
102
99
logging .error ("Repository name is missing in the request." )
103
100
return jsonify ({"status" : "Repository name is required." }), 400
104
101
105
102
# Validate 'node_id' parameter
106
- if not node_ids :
103
+ if not node_id :
107
104
logging .error ("Node ID is missing in the request." )
108
105
return jsonify ({"status" : "Node ID is required." }), 400
109
106
@@ -114,19 +111,19 @@ def get_neighbors():
114
111
115
112
# Try converting node_id to an integer
116
113
try :
117
- node_ids = [ int (node_id ) for node_id in node_ids ]
114
+ node_id = int (node_id )
118
115
except ValueError :
119
- logging .error (f"Invalid node ID: { node_ids } . It must be an integer." )
116
+ logging .error (f"Invalid node ID: { node_id } . It must be an integer." )
120
117
return jsonify ({"status" : "Invalid node ID. It must be an integer." }), 400
121
118
122
119
# Initialize the graph with the provided repository
123
120
g = Graph (repo )
124
121
125
122
# Fetch the neighbors of the specified node
126
- neighbors = g .get_neighbors (node_ids )
123
+ neighbors = g .get_neighbors (node_id )
127
124
128
125
# Log and return the neighbors
129
- logging .info (f"Successfully retrieved neighbors for node ID { node_ids } in repo '{ repo } '." )
126
+ logging .info (f"Successfully retrieved neighbors for node ID { node_id } in repo '{ repo } '." )
130
127
131
128
response = {
132
129
'status' : 'success' ,
@@ -173,41 +170,6 @@ def auto_complete():
173
170
174
171
return jsonify (response ), 200
175
172
176
- @app .route ('/process_repo' , methods = ['POST' ])
177
- @token_required # Apply token authentication decorator
178
- def process_repo ():
179
- """
180
- Process a GitHub repository.
181
-
182
- Expected JSON payload:
183
- {
184
- "repo_url": "string",
185
- "ignore": ["string"] # optional
186
- }
187
-
188
- Returns:
189
- JSON response with processing status
190
- """
191
-
192
- data = request .get_json ()
193
- url = data .get ('repo_url' )
194
- if url is None :
195
- return jsonify ({'status' : f'Missing mandatory parameter "url"' }), 400
196
- logger .debug (f'Received repo_url: { url } ' )
197
-
198
- ignore = data .get ('ignore' , [])
199
-
200
- proj = Project .from_git_repository (url )
201
- proj .analyze_sources (ignore )
202
- # proj.process_git_history(ignore)
203
-
204
- # Create a response
205
- response = {
206
- 'status' : 'success' ,
207
- }
208
-
209
- return jsonify (response ), 200
210
-
211
173
212
174
@app .route ('/list_repos' , methods = ['GET' ])
213
175
@token_required # Apply token authentication decorator
@@ -221,7 +183,7 @@ def list_repos():
221
183
222
184
# Fetch list of repositories
223
185
repos = get_repos ()
224
- print ( repos )
186
+
225
187
# Create a success response with the list of repositories
226
188
response = {
227
189
'status' : 'success' ,
0 commit comments