Skip to content

Commit 2644cc7

Browse files
[#702] User should aware that they need to set unique segment name
1 parent 1b3d057 commit 2644cc7

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

backend/routes/case.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,16 @@ def create_case(
5757
user = verify_case_creator(
5858
session=session, authenticated=req.state.authenticated
5959
)
60+
61+
if payload.segments:
62+
# Check for duplicate segment names in the payload
63+
segment_names = [seg.name for seg in payload.segments if seg.name]
64+
if len(segment_names) != len(set(segment_names)):
65+
raise HTTPException(
66+
status_code=400,
67+
detail="Failed to save case setting: The segments need to have unique names.", # noqa
68+
)
69+
6070
case = crud_case.add_case(session=session, payload=payload, user=user)
6171
# Update case_import with case_id if available in request state
6272
if payload.import_id and case:

frontend/src/pages/cases/components/CaseSettings.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,10 @@ const CaseSettings = ({ open = false, handleCancel = () => {} }) => {
577577
if (status === 403) {
578578
errorText = data.detail;
579579
}
580+
if (status === 400 && data?.detail?.includes("unique names")) {
581+
// should have unique segment name
582+
errorText = data.detail;
583+
}
580584
messageApi.open({
581585
type: "error",
582586
content: errorText,

frontend/src/pages/cases/components/SegmentConfigurationForm.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,9 @@ const SegmentConfigurationForm = ({
268268
)}
269269
{segmentationPreviews?.segments?.length > 0 && !loadingPreview && (
270270
<Col span={24} style={{ marginTop: 16 }}>
271-
<h3>
272-
Please review or adjust thresholds for separating segments below:
271+
<h3 style={{ fontSize: "16px" }}>
272+
Please create unique segment names and review/tweak thresholds for
273+
separating segments:
273274
</h3>
274275
<Row gutter={[20, 20]}>
275276
{segmentNumericalWarning}

0 commit comments

Comments
 (0)