Skip to content

Commit

Permalink
fix: вакансии без работо_владельца
Browse files Browse the repository at this point in the history
  • Loading branch information
s3rgeym committed Nov 11, 2024
1 parent 818c73a commit 10f9efe
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
37 changes: 25 additions & 12 deletions hh_applicant_tool/operations/apply_similar.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def _apply_similar(
if getenv("TEST_TELEMETRY"):
break

if vacancy["has_test"]:
if vacancy.get("has_test"):
print("🚫 Пропускаем тест", vacancy["alternate_url"])
continue

Expand All @@ -147,16 +147,23 @@ def _apply_similar(
)
continue

employer_id = vacancy["employer"]["id"]
employer = api.get(f"/employers/{employer_id}")
try:
employer_id = vacancy["employer"]["id"]
except IndexError:
logger.warning(
f"Вакансия без работодателя: {vacancy['alternate_url']}"
)
else:
employer = api.get(f"/employers/{employer_id}")

telemetry_data["employers"][employer_id] = {
"name": employer.get("name"),
"type": employer.get("type"),
"description": employer.get("description"),
"site_url": employer.get("site_url"),
"area": employer.get("area", {}).get("name"), # город
}

telemetry_data["employers"][employer_id] = {
"name": employer.get("name"),
"type": employer.get("type"),
"description": employer.get("description"),
"site_url": employer.get("site_url"),
"area": employer.get("area", {}).get("name"), # город
}
# Задержка перед отправкой отклика
interval = random.uniform(
apply_min_interval, apply_max_interval
Expand Down Expand Up @@ -242,15 +249,21 @@ def _collect_vacancy_telemetry(
"contacts": vacancy.get(
"contacts"
), # пиздорванки там телеграм для связи указывают
"employer_id": int(vacancy["employer"]["id"]),
# HH с точки зрения перфикциониста — кусок говна, где кривые
# форматы даты, у вакансий может не быть работодателя...
"employer_id": int(vacancy["employer"]["id"])
if "employer" in vacancy and "id" in vacancy["employer"]
else None,
# Остальное неинтересно
}

def _send_telemetry(
self, telemetry_client, telemetry_data: defaultdict
) -> None:
try:
res = telemetry_client.send_telemetry("/collect", dict(telemetry_data))
res = telemetry_client.send_telemetry(
"/collect", dict(telemetry_data)
)
logger.debug(res)
except TelemetryError as ex:
logger.error(ex)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "hh-applicant-tool"
version = "0.3.3"
version = "0.3.4"
description = ""
authors = ["Senior YAML Developer <[email protected]>"]
readme = "README.md"
Expand Down

0 comments on commit 10f9efe

Please sign in to comment.