ginipick commited on
Commit
38c180a
·
verified ·
1 Parent(s): b98dc44

Update app-backup.py

Browse files
Files changed (1) hide show
  1. app-backup.py +30 -16
app-backup.py CHANGED
@@ -27,7 +27,10 @@ def _load_best():
27
  print(f"BEST 데이터 로드 오류: {e}")
28
  return []
29
 
30
- # ───────────────────── 3. NEW: 프로젝트 API 호출 ─────────────────
 
 
 
31
  def fetch_all(limit=50):
32
  """
33
  Vercel API v10/projects를 사용하여 프로젝트 목록을 가져옵니다.
@@ -54,20 +57,28 @@ def fetch_all(limit=50):
54
  print(f"API 응답에 projects 필드가 없습니다: {str(data)[:200]}...")
55
  return []
56
 
57
- print(f"{len(data['projects'])}개의 프로젝트를 찾았습니다")
 
58
 
59
  # 각 프로젝트의 최신 배포 정보 가져오기
60
  games = []
61
- for project in data.get("projects", []):
62
  project_id = project.get("id")
63
  project_name = project.get("name", "(제목 없음)")
64
 
65
- # 프로젝트의 최신 배포 가져오기
66
  try:
67
- deploy_params = {"limit": 1, "target": "production"}
 
 
 
 
 
68
  if TEAM:
69
  deploy_params["teamId"] = TEAM
70
 
 
 
71
  deploy_resp = requests.get(
72
  f"{API}/v6/deployments",
73
  headers=HEAD,
@@ -81,20 +92,22 @@ def fetch_all(limit=50):
81
 
82
  if deployments:
83
  deployment = deployments[0]
84
- if deployment.get("state") == "READY":
85
- url = deployment.get("url", "")
86
- if url:
87
- games.append({
88
- "title": project_name,
89
- "url": f"https://{url}",
90
- "ts": int(deployment.get("created", time.time() * 1000) / 1000),
91
- "projectId": project_id
92
- })
 
 
93
  except Exception as e:
94
  print(f"프로젝트 {project_id}의 배포 정보 가져오기 실패: {e}")
95
  continue
96
 
97
- print(f"사용 가능한 배포 {len(games)}개를 찾았습니다")
98
  return sorted(games, key=lambda x: x["ts"], reverse=True)
99
 
100
  except Exception as e:
@@ -185,4 +198,5 @@ def build():
185
  app = build()
186
 
187
  if __name__ == "__main__":
188
- app.launch()
 
 
27
  print(f"BEST 데이터 로드 오류: {e}")
28
  return []
29
 
30
+
31
+
32
+
33
+
34
  def fetch_all(limit=50):
35
  """
36
  Vercel API v10/projects를 사용하여 프로젝트 목록을 가져옵니다.
 
57
  print(f"API 응답에 projects 필드가 없습니다: {str(data)[:200]}...")
58
  return []
59
 
60
+ projects = data.get("projects", [])
61
+ print(f"{len(projects)}개의 프로젝트를 찾았습니다")
62
 
63
  # 각 프로젝트의 최신 배포 정보 가져오기
64
  games = []
65
+ for project in projects:
66
  project_id = project.get("id")
67
  project_name = project.get("name", "(제목 없음)")
68
 
69
+ # 프로젝트별 최신 배포 가져오기 (projectId 필터 추가)
70
  try:
71
+ deploy_params = {
72
+ "limit": 1,
73
+ "projectId": project_id, # 중요: 해당 프로젝트의 배포만 필터링
74
+ "state": "READY"
75
+ }
76
+
77
  if TEAM:
78
  deploy_params["teamId"] = TEAM
79
 
80
+ print(f"프로젝트 {project_id} ({project_name}) 배포 조회 중...")
81
+
82
  deploy_resp = requests.get(
83
  f"{API}/v6/deployments",
84
  headers=HEAD,
 
92
 
93
  if deployments:
94
  deployment = deployments[0]
95
+ url = deployment.get("url", "")
96
+ if url:
97
+ games.append({
98
+ "title": project_name,
99
+ "url": f"https://{url}",
100
+ "ts": int(deployment.get("created", time.time() * 1000) / 1000),
101
+ "projectId": project_id
102
+ })
103
+ print(f"프로젝트 {project_name}의 배포 URL: https://{url}")
104
+ else:
105
+ print(f"프로젝트 {project_name}에 배포된 버전이 없습니다.")
106
  except Exception as e:
107
  print(f"프로젝트 {project_id}의 배포 정보 가져오기 실패: {e}")
108
  continue
109
 
110
+ print(f" {len(games)}개의 유효한 배포를 찾았습니다")
111
  return sorted(games, key=lambda x: x["ts"], reverse=True)
112
 
113
  except Exception as e:
 
198
  app = build()
199
 
200
  if __name__ == "__main__":
201
+ app.launch()
202
+