Spaces:
Sleeping
Sleeping
ichieh commited on
Commit ·
b54e9ca
1
Parent(s): 4671b30
Update data restoration to handle table settings first
Browse files
app.py
CHANGED
|
@@ -140,6 +140,23 @@ with app.app_context():
|
|
| 140 |
data = response.json()
|
| 141 |
|
| 142 |
if data.get('success'):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 143 |
participants_data = data.get('participants', [])
|
| 144 |
print(f"從 Google Sheets 找到 {len(participants_data)} 個參與者")
|
| 145 |
|
|
|
|
| 140 |
data = response.json()
|
| 141 |
|
| 142 |
if data.get('success'):
|
| 143 |
+
# 先恢復桌次設定
|
| 144 |
+
settings_data = data.get('settings', {})
|
| 145 |
+
total_tables = int(settings_data.get('total_tables', 10))
|
| 146 |
+
seats_per_table = int(settings_data.get('seats_per_table', 10))
|
| 147 |
+
print(f"從 Google Sheets 恢復設定:總桌數={total_tables}, 每桌人數={seats_per_table}")
|
| 148 |
+
|
| 149 |
+
# 清除現有的桌次
|
| 150 |
+
Table.query.delete()
|
| 151 |
+
|
| 152 |
+
# 創建新的桌次
|
| 153 |
+
for i in range(1, total_tables + 1):
|
| 154 |
+
table = Table(name=f"第 {i} 桌", capacity=seats_per_table)
|
| 155 |
+
db.session.add(table)
|
| 156 |
+
db.session.commit()
|
| 157 |
+
print("桌次設定恢復完成")
|
| 158 |
+
|
| 159 |
+
# 然後恢復參與者資料
|
| 160 |
participants_data = data.get('participants', [])
|
| 161 |
print(f"從 Google Sheets 找到 {len(participants_data)} 個參與者")
|
| 162 |
|