feat: professionalize platform release 0.3.13
deploy / deploy (push) Canceled after 0s

This commit is contained in:
Jens
2026-07-29 16:35:37 +02:00
parent 78fcf4fa5f
commit 5e2453c29a
40 changed files with 582 additions and 65 deletions
+30 -1
View File
@@ -4,6 +4,7 @@ from datetime import timedelta
from typing import Any
from django.conf import settings
from django.core.cache import cache
from django.db.models import Count, Q, Sum
from django.utils import timezone
@@ -14,6 +15,32 @@ from apps.profiles.models import SearchProfile
from apps.sources.models import Source, SourceRun
from ..health import readiness
from ..tasks import RUNTIME_HEARTBEAT_KEY
def _runtime_heartbeat_state() -> dict[str, Any]:
if settings.CELERY_TASK_ALWAYS_EAGER:
return {"label": "Eager/lokaal", "healthy": True, "observed_at": None}
raw_timestamp = cache.get(RUNTIME_HEARTBEAT_KEY)
if not raw_timestamp:
return {"label": "Geen recente heartbeat", "healthy": False, "observed_at": None}
try:
observed_at = timezone.datetime.fromisoformat(str(raw_timestamp))
if timezone.is_naive(observed_at):
observed_at = timezone.make_aware(observed_at)
except (TypeError, ValueError):
return {"label": "Ongeldige heartbeat", "healthy": False, "observed_at": None}
age_seconds = max(0, int((timezone.now() - observed_at).total_seconds()))
return {
"label": f"Actief · {age_seconds}s geleden"
if age_seconds <= 150
else "Heartbeat verouderd",
"healthy": age_seconds <= 150,
"observed_at": observed_at,
}
def build_automation_cockpit() -> dict[str, Any]:
@@ -84,6 +111,7 @@ def build_automation_cockpit() -> dict[str, Any]:
"unit": "verzonden / 24u",
},
]
runtime_heartbeat = _runtime_heartbeat_state()
return {
"health": readiness(),
"source_total": source_total,
@@ -103,7 +131,8 @@ def build_automation_cockpit() -> dict[str, Any]:
"source_rows": Source.objects.annotate(run_count=Count("runs")).order_by("name")[:12],
"queue_state": "Eager/lokaal"
if settings.CELERY_TASK_ALWAYS_EAGER
else "Geconfigureerd, worker niet gemeten",
else "Diepte niet beschikbaar",
"runtime_heartbeat": runtime_heartbeat,
"ai_state": "Geconfigureerd"
if settings.OLLAMA_ENABLED and settings.OLLAMA_MODEL
else "Niet geconfigureerd",
+17
View File
@@ -0,0 +1,17 @@
from __future__ import annotations
from celery import shared_task
from django.core.cache import cache
from django.utils import timezone
RUNTIME_HEARTBEAT_KEY = "vacatureradar:runtime:heartbeat"
RUNTIME_HEARTBEAT_TTL_SECONDS = 180
@shared_task(name="apps.core.tasks.record_runtime_heartbeat", ignore_result=True)
def record_runtime_heartbeat() -> str:
"""Record proof that beat dispatch and a worker execution both succeeded."""
timestamp = timezone.now().isoformat()
cache.set(RUNTIME_HEARTBEAT_KEY, timestamp, timeout=RUNTIME_HEARTBEAT_TTL_SECONDS)
return timestamp
+1 -1
View File
@@ -144,7 +144,7 @@ class JobListView(LoginRequiredMixin, ListView):
model = JobPosting
template_name = "jobs/list.html"
context_object_name = "jobs"
paginate_by = 30
paginate_by = 20
VALID_RECOMMENDATIONS = {
ScoreRun.Recommendation.STRONG,
+13 -1
View File
@@ -9,13 +9,15 @@ from .base import ExtractedJob, ExtractionResult, FieldEvidence
LABEL_PATTERNS = {
"location": re.compile(r"^(locatie|location|lieu|plaats|standplaats)\s*:?$", re.I),
"date_posted": re.compile(r"^(publicatiedatum|geplaatst|date posted|published)\s*:?$", re.I),
"employment_type": re.compile(r"^(dienstverband|contract|employment type)\s*:?$", re.I),
"employer": re.compile(r"^(werkgever|employer|company|organisatie|société)\s*:?$", re.I),
}
class GenericHtmlAdapter:
parser_key = "generic-html"
parser_version = "1.0.0"
parser_version = "1.1.0"
@staticmethod
def _meta(soup: BeautifulSoup, *names: str) -> str:
@@ -59,6 +61,8 @@ class GenericHtmlAdapter:
soup, LABEL_PATTERNS["employer"]
)
location = self._label_value(soup, LABEL_PATTERNS["location"])
date_posted = self._label_value(soup, LABEL_PATTERNS["date_posted"])
employment_type = self._label_value(soup, LABEL_PATTERNS["employment_type"])
main = soup.find("main") or soup.find("article") or soup.body
description_html = str(main) if main else ""
description_text = (
@@ -74,6 +78,12 @@ class GenericHtmlAdapter:
FieldEvidence("location_text", "html-label", 0.62, location[:240]),
FieldEvidence("description", "html-main", 0.70, description_text[:300]),
]
if date_posted:
evidence.append(FieldEvidence("date_posted", "html-label", 0.62, date_posted[:40]))
if employment_type:
evidence.append(
FieldEvidence("employment_types", "html-label", 0.62, employment_type[:120])
)
job = ExtractedJob(
url=job_url,
title=title,
@@ -81,6 +91,8 @@ class GenericHtmlAdapter:
location_text=location,
description_html=description_html,
description_text=description_text,
date_posted=date_posted,
employment_types=[employment_type] if employment_type else [],
raw={"generic_html": True},
evidence=evidence,
)