分页优化
This commit is contained in:
+31
-5
@@ -247,11 +247,21 @@ class ServerAPI:
|
||||
return resp.json().get("applied", False)
|
||||
|
||||
def list_blacklist(self) -> list[str]:
|
||||
"""公司黑名单名单(公司名列表,拉黑后不再投递该公司)"""
|
||||
resp = self._req("get", f"{self.base_url}/api/blacklist",
|
||||
headers=self._headers(), timeout=15)
|
||||
resp.raise_for_status()
|
||||
return [i["company"] for i in resp.json()]
|
||||
"""公司黑名单名单(公司名列表,拉黑后不再投递该公司)。
|
||||
接口分页返回,这里翻页拉全(黑名单用于投递前过滤,必须拿到全量)"""
|
||||
companies: list[str] = []
|
||||
page = 1
|
||||
while True:
|
||||
resp = self._req("get", f"{self.base_url}/api/blacklist",
|
||||
params={"page": page, "page_size": 100},
|
||||
headers=self._headers(), timeout=15)
|
||||
resp.raise_for_status()
|
||||
data = resp.json()
|
||||
companies.extend(i["company"] for i in data.get("items", []))
|
||||
if page >= data.get("pages", 1) or page >= 10:
|
||||
break
|
||||
page += 1
|
||||
return companies
|
||||
|
||||
def get_stats(self) -> dict:
|
||||
resp = self._req("get", f"{self.base_url}/api/jobs/stats", headers=self._headers(), timeout=15)
|
||||
@@ -275,6 +285,22 @@ class ServerAPI:
|
||||
resp.raise_for_status()
|
||||
return resp.json()
|
||||
|
||||
def get_history_page(self, page: int = 1, page_size: int = 20,
|
||||
apply_type: str | None = None,
|
||||
start: str | None = None, end: str | None = None) -> dict:
|
||||
"""投递记录分页筛选(北京时间范围 + 投递结果,时间倒序)"""
|
||||
params: dict = {"page": page, "page_size": page_size}
|
||||
if apply_type:
|
||||
params["apply_type"] = apply_type
|
||||
if start:
|
||||
params["start"] = start
|
||||
if end:
|
||||
params["end"] = end
|
||||
resp = self._req("get", f"{self.base_url}/api/jobs/page",
|
||||
params=params, headers=self._headers(), timeout=15)
|
||||
resp.raise_for_status()
|
||||
return resp.json()
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# 连通性
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user