refaktorálás javításai
This commit is contained in:
@@ -76,10 +76,10 @@ class ServiceResearcher:
|
||||
async with AsyncSessionLocal() as db:
|
||||
# ATOMI ZÁROLÁS
|
||||
query = text("""
|
||||
UPDATE data.service_staging
|
||||
UPDATE marketplace.service_staging
|
||||
SET status = 'research_in_progress'
|
||||
WHERE id = (
|
||||
SELECT id FROM data.service_staging
|
||||
SELECT id FROM marketplace.service_staging
|
||||
WHERE status = 'pending'
|
||||
FOR UPDATE SKIP LOCKED
|
||||
LIMIT 1
|
||||
|
||||
@@ -59,10 +59,10 @@ class ServiceEnricher:
|
||||
async with AsyncSessionLocal() as db:
|
||||
# 1. Zárolunk egy "enrich_ready" szervizt a Staging táblából
|
||||
query = text("""
|
||||
UPDATE data.service_staging
|
||||
UPDATE marketplace.service_staging
|
||||
SET status = 'enriching'
|
||||
WHERE id = (
|
||||
SELECT id FROM data.service_staging
|
||||
SELECT id FROM marketplace.service_staging
|
||||
WHERE status = 'enrich_ready'
|
||||
FOR UPDATE SKIP LOCKED
|
||||
LIMIT 1
|
||||
@@ -81,7 +81,7 @@ class ServiceEnricher:
|
||||
try:
|
||||
# 2. Áttesszük a végleges ServiceProfile táblába (mert már van elég adatunk a webről)
|
||||
profile_stmt = text("""
|
||||
INSERT INTO data.service_profiles
|
||||
INSERT INTO marketplace.service_profiles
|
||||
(fingerprint, status, trust_score, location, is_verified, bio)
|
||||
VALUES (:fp, 'active', 40, ST_SetSRID(ST_MakePoint(19.04, 47.49), 4326), false, :bio)
|
||||
ON CONFLICT (fingerprint) DO UPDATE SET bio = EXCLUDED.bio
|
||||
@@ -96,13 +96,13 @@ class ServiceEnricher:
|
||||
await cls.match_expertise_to_service(process_db, profile_id, web_context)
|
||||
|
||||
# 4. Lezárjuk a Staging feladatot
|
||||
await process_db.execute(text("UPDATE data.service_staging SET status = 'processed' WHERE id = :id"), {"id": s_id})
|
||||
await process_db.execute(text("UPDATE marketplace.service_staging SET status = 'processed' WHERE id = :id"), {"id": s_id})
|
||||
await process_db.commit()
|
||||
|
||||
except Exception as e:
|
||||
await process_db.rollback()
|
||||
logger.error(f"Hiba a dúsítás során ({s_id}): {e}")
|
||||
await process_db.execute(text("UPDATE data.service_staging SET status = 'error' WHERE id = :id"), {"id": s_id})
|
||||
await process_db.execute(text("UPDATE marketplace.service_staging SET status = 'error' WHERE id = :id"), {"id": s_id})
|
||||
await process_db.commit()
|
||||
else:
|
||||
await asyncio.sleep(15)
|
||||
|
||||
@@ -158,11 +158,11 @@ class GoogleValidator:
|
||||
async with AsyncSessionLocal() as db:
|
||||
# ATOMI ZÁROLÁS: Keresünk egy aktív, de még nem validált szervizt
|
||||
query = text("""
|
||||
UPDATE data.service_profiles
|
||||
UPDATE marketplace.service_profiles
|
||||
SET status = 'validation_in_progress'
|
||||
WHERE id = (
|
||||
SELECT id FROM data.service_profiles
|
||||
WHERE is_verified = false
|
||||
SELECT id FROM marketplace.service_profiles
|
||||
WHERE is_verified = false
|
||||
AND status NOT IN ('validation_in_progress', 'ghost')
|
||||
FOR UPDATE SKIP LOCKED
|
||||
LIMIT 1
|
||||
@@ -181,7 +181,7 @@ class GoogleValidator:
|
||||
|
||||
# Ha API hiba volt, visszaállítjuk az eredeti állapotot
|
||||
if status == "ERROR":
|
||||
await process_db.execute(text("UPDATE data.service_profiles SET status = 'active' WHERE id = :id"), {"id": p_id})
|
||||
await process_db.execute(text("UPDATE marketplace.service_profiles SET status = 'active' WHERE id = :id"), {"id": p_id})
|
||||
await process_db.commit()
|
||||
|
||||
if status == "QUOTA_EXCEEDED":
|
||||
|
||||
Reference in New Issue
Block a user