feat: add boilerplate

This commit is contained in:
2026-10-26 21:56:23 +01:00
commit cc6675f7c6
29 changed files with 2231 additions and 0 deletions

45
app/seed.py Normal file
View File

@@ -0,0 +1,45 @@
import json
from pathlib import Path
from sqlalchemy.orm import Session
from app.models import Job
from app.ral import hide_salary
def seed_jobs(db: Session) -> int:
path = Path(__file__).resolve().parent.parent / "seed_jobs.json"
if not path.exists():
return 0
jobs = json.loads(path.read_text(encoding="utf-8"))
created = 0
for item in jobs:
exists = (
db.query(Job)
.filter(Job.title == item["title"], Job.company == item["company"])
.first()
)
if exists:
continue
description = item["description"]
db.add(
Job(
title=item["title"],
company=item["company"],
subject=item.get("subject", "other"),
location=item.get("location", ""),
description=description,
description_clean=hide_salary(description),
extra_info=item.get("extra_info", ""),
ral_min=item.get("ral_min"),
ral_max=item.get("ral_max"),
ral_exact=item.get("ral_exact"),
work_type=item.get("work_type", "hybrid"),
difficulty=item.get("difficulty", 1),
status="ready",
source="seed",
)
)
created += 1
db.commit()
return created