@@ -79,28 +79,31 @@ def graph_entities():
79
79
return jsonify ({"status" : "Internal server error" }), 500
80
80
81
81
82
- @app .route ('/get_neighbors' , methods = ['GET ' ])
82
+ @app .route ('/get_neighbors' , methods = ['POST ' ])
83
83
@token_required # Apply token authentication decorator
84
84
def get_neighbors ():
85
85
"""
86
- Endpoint to get neighbors of a specific node in the graph.
87
- Expects 'repo' and 'node_id ' as query parameters.
86
+ Endpoint to get neighbors of a nodes list in the graph.
87
+ Expects 'repo' and 'node_ids ' as body 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
+
93
96
# Get query parameters
94
- repo = request . args .get ('repo' )
95
- node_id = request . args . get ('node_id ' )
97
+ repo = data .get ('repo' )
98
+ node_ids = data . get ('node_ids ' )
96
99
97
100
# Validate 'repo' parameter
98
101
if not repo :
99
102
logging .error ("Repository name is missing in the request." )
100
103
return jsonify ({"status" : "Repository name is required." }), 400
101
104
102
105
# Validate 'node_id' parameter
103
- if not node_id :
106
+ if not node_ids :
104
107
logging .error ("Node ID is missing in the request." )
105
108
return jsonify ({"status" : "Node ID is required." }), 400
106
109
@@ -111,19 +114,19 @@ def get_neighbors():
111
114
112
115
# Try converting node_id to an integer
113
116
try :
114
- node_id = int (node_id )
117
+ node_ids = [ int (node_id ) for node_id in node_ids ]
115
118
except ValueError :
116
- logging .error (f"Invalid node ID: { node_id } . It must be an integer." )
119
+ logging .error (f"Invalid node ID: { node_ids } . It must be an integer." )
117
120
return jsonify ({"status" : "Invalid node ID. It must be an integer." }), 400
118
121
119
122
# Initialize the graph with the provided repository
120
123
g = Graph (repo )
121
124
122
125
# Fetch the neighbors of the specified node
123
- neighbors = g .get_neighbors (node_id )
126
+ neighbors = g .get_neighbors (node_ids )
124
127
125
128
# Log and return the neighbors
126
- logging .info (f"Successfully retrieved neighbors for node ID { node_id } in repo '{ repo } '." )
129
+ logging .info (f"Successfully retrieved neighbors for node ID { node_ids } in repo '{ repo } '." )
127
130
128
131
response = {
129
132
'status' : 'success' ,
@@ -170,6 +173,41 @@ def auto_complete():
170
173
171
174
return jsonify (response ), 200
172
175
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
+
173
211
174
212
@app .route ('/list_repos' , methods = ['GET' ])
175
213
@token_required # Apply token authentication decorator
@@ -183,7 +221,7 @@ def list_repos():
183
221
184
222
# Fetch list of repositories
185
223
repos = get_repos ()
186
-
224
+ print ( repos )
187
225
# Create a success response with the list of repositories
188
226
response = {
189
227
'status' : 'success' ,
0 commit comments