Skip to content

Commit 0e5939b

Browse files
abhizipstackclaude
andcommitted
fix: address review comments — deduplicate URL prefix, preserve response status codes
- Move transformation router to dedicated prefix project/<project_id>/no_code_model/ instead of duplicate "project" prefix - Remove status code override in handle_http_request — let views return their intended status codes (201, 204, etc.) instead of forcing 200 - Normalize generate_formula param from model_name to file_name for consistency with URL pattern Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 6ef1162 commit 0e5939b

4 files changed

Lines changed: 16 additions & 50 deletions

File tree

backend/backend/core/routers/transformation/urls.py

Lines changed: 10 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -12,50 +12,15 @@
1212
validate_model_file,
1313
)
1414

15+
# Mounted at: project/<project_id>/no_code_model/
1516
urlpatterns = [
16-
path(
17-
"/<str:project_id>/no_code_model/<str:file_name>/validate",
18-
validate_model_file,
19-
name="validate-no-code-model-file",
20-
),
21-
path(
22-
"/<str:project_id>/no_code_model/<str:file_name>/set-model",
23-
set_model_config_and_reference,
24-
name="set-no-code-model-config",
25-
),
26-
path(
27-
"/<str:project_id>/no_code_model/<str:file_name>/set-transform",
28-
set_model_transformation,
29-
name="set-no-code-model-transformation",
30-
),
31-
path(
32-
"/<str:project_id>/no_code_model/<str:file_name>/delete-transform",
33-
delete_model_transformation,
34-
name="delete-no-code-model-transformation",
35-
),
36-
path(
37-
"/<str:project_id>/no_code_model/<str:file_name>/set-presentation",
38-
set_model_presentation,
39-
name="set-no-code-model-presentation",
40-
),
41-
path(
42-
"/<str:project_id>/no_code_model/<str:file_name>/columns",
43-
get_transformation_columns,
44-
name="get-transformation-columns",
45-
),
46-
path(
47-
"/<str:project_id>/no_code_model/<str:file_name>/supported_references",
48-
get_supported_models,
49-
name="get-supported-reference-models",
50-
),
51-
path(
52-
"/<str:project_id>/no_code_model/<str:file_name>",
53-
save_model_file,
54-
name="save-no-code-model-file",
55-
),
56-
path(
57-
"/<str:project_id>/no_code_model/<str:model_name>/generate_formula",
58-
generate_formula,
59-
name="generate-formula",
60-
),
17+
path("<str:file_name>/validate", validate_model_file, name="validate-no-code-model-file"),
18+
path("<str:file_name>/set-model", set_model_config_and_reference, name="set-no-code-model-config"),
19+
path("<str:file_name>/set-transform", set_model_transformation, name="set-no-code-model-transformation"),
20+
path("<str:file_name>/delete-transform", delete_model_transformation, name="delete-no-code-model-transformation"),
21+
path("<str:file_name>/set-presentation", set_model_presentation, name="set-no-code-model-presentation"),
22+
path("<str:file_name>/columns", get_transformation_columns, name="get-transformation-columns"),
23+
path("<str:file_name>/supported_references", get_supported_models, name="get-supported-reference-models"),
24+
path("<str:file_name>/generate_formula", generate_formula, name="generate-formula"),
25+
path("<str:file_name>", save_model_file, name="save-no-code-model-file"),
6126
]

backend/backend/core/routers/transformation/views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,13 @@ def get_supported_models(request: Request, project_id: str, file_name: str) -> R
211211
@api_view([HTTPMethods.POST])
212212
@handle_http_request
213213
@handle_permission
214-
def generate_formula(request: Request, project_id: str, model_name: str) -> Response:
214+
def generate_formula(request: Request, project_id: str, file_name: str) -> Response:
215215
# Generate Excel Formula based on the User prompt with OpenAi support
216216
user_prompt = request.data["user_prompt"]
217217
app = FormulaContext(project_id=project_id)
218218

219219
# Get schema details and construct the prompt
220-
schema_details = app.get_schema_details(model_name)
220+
schema_details = app.get_schema_details(file_name)
221221
constructed_prompt = app.construct_prompt(user_prompt, schema_details)
222222

223223
# Generate the formula

backend/backend/core/urls.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@
1919
path("token", include("backend.core.routers.api_tokens.urls")),
2020
path("connection", include("backend.core.routers.connection.urls")),
2121
path("environment", include("backend.core.routers.environment.urls")),
22-
path("project", include("backend.core.routers.transformation.urls")),
2322
path("project", include("backend.core.routers.projects.urls")),
23+
path(
24+
"project/<str:project_id>/no_code_model/",
25+
include("backend.core.routers.transformation.urls"),
26+
),
2427
path("onboarding/", include("backend.core.routers.onboarding.urls")),
2528
path(
2629
"project/<str:project_id>/connection",

backend/backend/core/utils.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ def handle_exceptions(*args, **kwargs) -> Response:
3737
)
3838
cache.set(lock_key, True, timeout=120)
3939
response: Response = func(*args, **kwargs)
40-
if response.status_code < 400:
41-
response.status_code = status.HTTP_200_OK
4240
logging.info(f"Deleting lock - {lock_key}")
4341
cache.delete(lock_key)
4442
return response

0 commit comments

Comments
 (0)