Ritesh1035 commited on
Commit
5ed79cd
·
verified ·
1 Parent(s): e50b000

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +6 -2
src/streamlit_app.py CHANGED
@@ -83,8 +83,12 @@ elif operation == "Add Customer":
83
  else:
84
  # Auto-generate ID based on existing customers count
85
  try:
86
- existing_customers = requests.get("https://ritesh1035-cms-apis.hf.space").json()
87
- customer_id = len(existing_customers) + 1
 
 
 
 
88
  except:
89
  customer_id = 1
90
 
 
83
  else:
84
  # Auto-generate ID based on existing customers count
85
  try:
86
+ existing_customers = requests.get("https://ritesh1035-cms-apis.hf.space/Customer").json()
87
+ if existing_customers:
88
+ max_id = max(customer.get('id', 0) for customer in existing_customers)
89
+ customer_id = max_id + 1
90
+ else:
91
+ customer_id = 1
92
  except:
93
  customer_id = 1
94