Read BB sync status from per-ship apply state
This commit is contained in:
+16
-16
@@ -445,11 +445,13 @@ def bb_sync_info(account_id):
|
||||
regions = {
|
||||
"us": {
|
||||
"host": "psopeeps_us",
|
||||
"targets": ["us-live", "us-test", "us-hardcore"],
|
||||
"status": "pending",
|
||||
"applied_at": None,
|
||||
},
|
||||
"eu": {
|
||||
"host": "psopeeps_eu",
|
||||
"targets": ["eu-live", "eu-test", "eu-hardcore"],
|
||||
"status": "pending",
|
||||
"applied_at": None,
|
||||
},
|
||||
@@ -463,17 +465,21 @@ def bb_sync_info(account_id):
|
||||
}
|
||||
|
||||
for region, info in regions.items():
|
||||
state_path = root / "state" / "applied" / f"{info['host']}.site.{aid}.json"
|
||||
state = read_json_file(state_path)
|
||||
applied_times = []
|
||||
all_current = True
|
||||
|
||||
if state and state.get("manifest_sha256") == manifest_sha:
|
||||
info["status"] = "current"
|
||||
info["applied_at"] = state.get("applied_at")
|
||||
elif state:
|
||||
info["status"] = "pending"
|
||||
info["applied_at"] = state.get("applied_at")
|
||||
else:
|
||||
info["status"] = "pending"
|
||||
for target in info["targets"]:
|
||||
state_path = root / "state" / "applied" / f"{info['host']}.{target}.site.{aid}.json"
|
||||
state = read_json_file(state_path)
|
||||
|
||||
if state and state.get("applied_at"):
|
||||
applied_times.append(state.get("applied_at"))
|
||||
|
||||
if not state or state.get("manifest_sha256") != manifest_sha:
|
||||
all_current = False
|
||||
|
||||
info["status"] = "current" if all_current else "pending"
|
||||
info["applied_at"] = max(applied_times) if applied_times else None
|
||||
|
||||
overall = "current" if all(x["status"] == "current" for x in regions.values()) else "pending"
|
||||
|
||||
@@ -484,12 +490,6 @@ def bb_sync_info(account_id):
|
||||
}
|
||||
|
||||
|
||||
|
||||
def account_sync_current_on_all_regions(account_id):
|
||||
sync = bb_sync_info(account_id)
|
||||
return sync.get("status") == "current", sync
|
||||
|
||||
|
||||
def bb_payload(account_id, username):
|
||||
sync = bb_sync_info(account_id)
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user