openfree commited on
Commit
3ad182b
โ€ข
1 Parent(s): f872762

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -11
app.py CHANGED
@@ -193,9 +193,13 @@ def get_space_card(space, index):
193
  """
194
 
195
  def get_vercel_deployments():
196
- """Vercel API๋ฅผ ํ†ตํ•ด ๋ฐฐํฌ๋œ ์„œ๋น„์Šค ์ •๋ณด ๊ฐ€์ ธ์˜ค๊ธฐ"""
197
  token = "A8IFZmgW2cqA4yUNlLPnci0N"
198
- url = "https://api.vercel.com/v6/deployments?limit=100"
 
 
 
 
199
 
200
  headers = {
201
  "Authorization": f"Bearer {token}",
@@ -203,25 +207,48 @@ def get_vercel_deployments():
203
  }
204
 
205
  try:
206
- response = requests.get(url, headers=headers)
207
- print(f"Debug - Vercel API status code: {response.status_code}") # ๋””๋ฒ„๊น… ๋กœ๊ทธ
208
- print(f"Debug - Vercel API response: {response.text[:500]}") # ์‘๋‹ต ๋‚ด์šฉ ์ผ๋ถ€ ์ถœ๋ ฅ
209
-
210
- if response.status_code != 200:
211
- print(f"Vercel API Error: {response.text}")
212
- return []
 
 
 
 
 
 
 
 
213
 
214
- deployments = response.json().get('deployments', [])
 
 
 
 
 
 
 
 
 
 
 
 
 
215
 
216
  # ์ƒํƒœ๊ฐ€ 'READY'์ด๊ณ  'url'์ด ์žˆ๋Š” ๋ฐฐํฌ๋งŒ ํ•„ํ„ฐ๋งํ•˜๊ณ  'javis1' ์ œ์™ธ
217
  active_deployments = [
218
- dep for dep in deployments
219
  if dep.get('state') == 'READY' and
220
  dep.get('url') and
221
  'javis1' not in dep.get('name', '').lower()
222
  ]
223
 
 
224
  return active_deployments
 
225
  except Exception as e:
226
  print(f"Error fetching Vercel deployments: {str(e)}")
227
  return []
 
193
  """
194
 
195
  def get_vercel_deployments():
196
+ """Vercel API๋ฅผ ํ†ตํ•ด ๋ชจ๋“  ๋ฐฐํฌ๋œ ์„œ๋น„์Šค ์ •๋ณด ๊ฐ€์ ธ์˜ค๊ธฐ (ํŽ˜์ด์ง€๋„ค์ด์…˜ ์ ์šฉ)"""
197
  token = "A8IFZmgW2cqA4yUNlLPnci0N"
198
+ base_url = "https://api.vercel.com/v6/deployments"
199
+ all_deployments = []
200
+ has_next = True
201
+ page = 1
202
+ until = None # ์ฒซ ์š”์ฒญ์—์„œ๋Š” until ํŒŒ๋ผ๋ฏธํ„ฐ ์—†์Œ
203
 
204
  headers = {
205
  "Authorization": f"Bearer {token}",
 
207
  }
208
 
209
  try:
210
+ while has_next:
211
+ # URL ๊ตฌ์„ฑ (ํŽ˜์ด์ง€๋„ค์ด์…˜ ํŒŒ๋ผ๋ฏธํ„ฐ ํฌํ•จ)
212
+ url = f"{base_url}?limit=100"
213
+ if until:
214
+ url += f"&until={until}"
215
+
216
+ print(f"Fetching page {page}... URL: {url}") # ๋””๋ฒ„๊น…์šฉ
217
+
218
+ response = requests.get(url, headers=headers)
219
+ if response.status_code != 200:
220
+ print(f"Vercel API Error: {response.text}")
221
+ break
222
+
223
+ data = response.json()
224
+ current_deployments = data.get('deployments', [])
225
 
226
+ if not current_deployments: # ๋” ์ด์ƒ ๋ฐ์ดํ„ฐ๊ฐ€ ์—†์œผ๋ฉด ์ข…๋ฃŒ
227
+ break
228
+
229
+ all_deployments.extend(current_deployments)
230
+
231
+ # ๋‹ค์Œ ํŽ˜์ด์ง€๋ฅผ ์œ„ํ•œ until ๊ฐ’ ์„ค์ •
232
+ pagination = data.get('pagination', {})
233
+ until = pagination.get('next')
234
+ has_next = bool(until) # until ๊ฐ’์ด ์žˆ์œผ๋ฉด ๋‹ค์Œ ํŽ˜์ด์ง€ ์กด์žฌ
235
+
236
+ print(f"Page {page} fetched. Got {len(current_deployments)} deployments") # ๋””๋ฒ„๊น…์šฉ
237
+ page += 1
238
+
239
+ print(f"Total deployments fetched: {len(all_deployments)}") # ๋””๋ฒ„๊น…์šฉ
240
 
241
  # ์ƒํƒœ๊ฐ€ 'READY'์ด๊ณ  'url'์ด ์žˆ๋Š” ๋ฐฐํฌ๋งŒ ํ•„ํ„ฐ๋งํ•˜๊ณ  'javis1' ์ œ์™ธ
242
  active_deployments = [
243
+ dep for dep in all_deployments
244
  if dep.get('state') == 'READY' and
245
  dep.get('url') and
246
  'javis1' not in dep.get('name', '').lower()
247
  ]
248
 
249
+ print(f"Active deployments after filtering: {len(active_deployments)}") # ๋””๋ฒ„๊น…์šฉ
250
  return active_deployments
251
+
252
  except Exception as e:
253
  print(f"Error fetching Vercel deployments: {str(e)}")
254
  return []