extending logging
This commit is contained in:
17
web/db.py
17
web/db.py
@@ -272,7 +272,7 @@ def get_last_fetch_time(page_url: str) -> Optional[datetime]:
|
||||
return None
|
||||
|
||||
|
||||
def upsert_job_details(job_data: Dict[str, Any]):
|
||||
def upsert_job_details(job_data: Dict[str, Any], region: str = "", keyword: str = ""):
|
||||
"""Upsert into job_descriptions table using scraped job details dict.
|
||||
|
||||
Behavior additions:
|
||||
@@ -356,7 +356,7 @@ SELECT l.job_id
|
||||
,d.posted_time
|
||||
,l.url
|
||||
FROM job_listings AS l
|
||||
INNER JOIN job_descriptions AS d
|
||||
INNER JOIN job_descriptions AS d
|
||||
ON l.job_id = d.job_id
|
||||
AND l.url = d.url
|
||||
ORDER BY d.posted_time DESC
|
||||
@@ -381,11 +381,16 @@ ORDER BY d.posted_time DESC
|
||||
return jobs
|
||||
|
||||
|
||||
def db_get_all_job_urls() -> List[str]:
|
||||
"""Return list of job URLs from job_listings."""
|
||||
def db_get_all_job_urls() -> List[dict]:
|
||||
"""Return list of job URLs from job_listings.
|
||||
|
||||
Returns:
|
||||
- List of dicts with keys: url, region, keyword
|
||||
"""
|
||||
with _ensure_session() as session:
|
||||
rows = session.execute(text("SELECT url FROM job_listings")).fetchall()
|
||||
return [r[0] for r in rows]
|
||||
rows = session.execute(
|
||||
text("SELECT url, region, keyword FROM job_listings")).fetchall()
|
||||
return [{"url": r[0], "region": r[1], "keyword": r[2]} for r in rows]
|
||||
|
||||
|
||||
def db_delete_job(job_id: str | int):
|
||||
|
||||
Reference in New Issue
Block a user