Skip to content

Commit

Permalink
Implement Freedom's Flame
Browse files Browse the repository at this point in the history
Minor Fixes
  • Loading branch information
chatterchats committed Sep 1, 2024
1 parent a26db84 commit d16740a
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 14 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
.idea/

.github/
.venv/
!env/.env.example
3 changes: 2 additions & 1 deletion src/cfg/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"User-Agent": "Diveharder API - api.diverharder.com",
"Authorization": os.environ["SESSION_TOKEN"],
},
"time_delay": 20,
"time_delay": int(20),
}


Expand Down Expand Up @@ -51,6 +51,7 @@
"season_pass_ce": base_url + os.environ["SEASON_PASS_CE"],
"season_pass_dd": base_url + os.environ["SEASON_PASS_DD"],
"season_pass_pp": base_url + os.environ["SEASON_PASS_PP"],
"season_pass_ff": base_url + os.environ["SEASON_PASS_FF"],
"score_calc": base_url + os.environ["MISSION_SCORE_CALC_PARAMS"],
"election_candidates": base_url + os.environ["ELECTION_CANDIDATES"],
"election_terms": base_url + os.environ["ELECTION_TERMS"],
Expand Down
5 changes: 3 additions & 2 deletions src/data/api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __init__(self):
self.urls = cfg.urls

self.update_time = 0
self.time_delay = cfg.ahgs_api.get("time_delay")
self.time_delay: int = cfg.ahgs_api.get("time_delay", 20)

self.raw_data = {
"status": {"data": [], "update_time": 0, "auth": True},
Expand All @@ -41,6 +41,7 @@ def __init__(self):
"season_pass_ce": {"data": [], "update_time": 0, "auth": True},
"season_pass_dd": {"data": [], "update_time": 0, "auth": True},
"season_pass_pp": {"data": [], "update_time": 0, "auth": True},
"season_pass_ff": {"data": [], "update_time": 0, "auth": True},
"score_calc": {"data": [], "update_time": 0, "auth": True},
"election_candidates": {"data": [], "update_time": 0, "auth": True},
"election_terms": {"data": [], "update_time": 0, "auth": True},
Expand Down Expand Up @@ -99,7 +100,7 @@ async def fetch_data(self, info_name: str = ""):
)
)
if update_needed:
authed = self.raw_data.get(info_name)["auth"]
authed = self.raw_data.get(info_name, {})["auth"]
url = self.urls[info_name]
self.raw_data[info_name]["update_time"] = int(time())
self.raw_data[info_name]["data"] = await self.get_url(url, authed)
Expand Down
4 changes: 3 additions & 1 deletion src/data/json_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ def sort_json_dicts():
"cutting_edge": raw_json_data["warbonds_cutting_edge"],
"democratic_detonation": raw_json_data["warbonds_democratic_detonation"],
"polar_patriots": raw_json_data["warbonds_polar_patriots"],
"viper_commandos": raw_json_data["warbonds_viper_commandos"],
"freedoms_flame": raw_json_data["warbonds_freedoms_flame"],
},
"factions": raw_json_data["factions"],
}
Expand Down Expand Up @@ -161,7 +163,7 @@ def expand_json():
page["assets"][item_id].update(
json_data["items"]["weapons"]["grenades"][item_id]
)
page["assets"][item_id].update({"medal_cost": item["medal_cost"]})
page["assets"][item_id].update({"medal_cost": item.get("medal_cost", 0)})
page["items"] = page["assets"]
page.pop("assets")

Expand Down
2 changes: 1 addition & 1 deletion src/routes/raw.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ async def get_raw_major_order(request: Request):


@router.get("/personal_order", status_code=200)
async def get_raw_major_order(request: Request):
async def get_raw_personal_order(request: Request):
"""Get the raw data for personal_order"""
log.info(request, status.HTTP_200_OK)
await api.fetch_data(info_name="personal_order")
Expand Down
7 changes: 6 additions & 1 deletion src/routes/response_models/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ class GlobalEvent(BaseModel):
planetIndices: List[int] | None


class PlanetActiveEffects(BaseModel):
index: int
galacticEffectId: int


class StatusResponse(BaseModel):
warId: int
time: int
Expand All @@ -67,7 +72,7 @@ class StatusResponse(BaseModel):
communityTargets: List[int] | None
jointOperations: List[JointOperation]
planetEvents: List[PlanetEvent]
planetActiveEffects: List[int] | None
planetActiveEffects: List[PlanetActiveEffects] | None
activeElectionPolicyEffects: List[int] | None
globalEvents: list[GlobalEvent]
superEarthWarResults: List[int] | None
Expand Down
4 changes: 2 additions & 2 deletions src/routes/response_models/war_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@


class PlanetCoords(BaseModel):
x: int
y: int
x: float
y: float


class PlanetInfo(BaseModel):
Expand Down
15 changes: 10 additions & 5 deletions src/routes/v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,14 +403,12 @@ async def update_store_data(data):
for item in data.get("salesPage", {}).get("sections", [{}])[0].get("items", {})
]
store_items = []

for k, v in helper_data["item_list"].items():
if (v["mix_id"] not in raw_store_items and k not in raw_store_items) or (
v["mix_id"] in store_items or k in store_items
):
if (
v["mix_id"] not in raw_store_items and k not in raw_store_items
): # or (v["mix_id"] in store_items or k in store_items):
continue
elif v["mix_id"] in raw_store_items or k in raw_store_items:
print("Item ID", k, "Mix ID", v["mix_id"])
if k in json_data["items"]["armor"]:
store_items.append(k)

Expand All @@ -424,4 +422,11 @@ async def update_store_data(data):
items.append(item_data)
else:
items.append({"name": "Unmapped"})
if not items:
items: List[dict[str, str]] = [
{"name": "Unmapped"},
{"name": "Unmapped"},
{"name": "Unmapped"},
{"name": "Unmapped"},
]
return {"expire_time": expire_time, "items": items}

0 comments on commit d16740a

Please sign in to comment.