STABLE: Final schema sync, optimized gitignore

This commit is contained in:
Kincses
2026-02-26 08:19:25 +01:00
parent 893f39fa15
commit 505543330a
203 changed files with 11590 additions and 9542 deletions

View File

@@ -1,3 +1,4 @@
# /opt/docker/dev/service_finder/backend/app/services/search_service.py
from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy import select, func
from app.models.service import ServiceProfile, ExpertiseTag, ServiceExpertise
@@ -15,36 +16,29 @@ class SearchService:
is_premium: bool = False
):
"""
Keresés távolság és szakértelem alapján.
Premium: Trust Score + Valós távolság.
Free: Trust Score + Légvonal.
Keresés távolság és szakértelem alapján PostGIS funkciókkal.
"""
user_point = ST_MakePoint(lon, lat) # PostGIS pont létrehozása
user_point = ST_MakePoint(lon, lat)
# Alap lekérdezés: ServiceProfile + Organization adatok
# Alap lekérdezés joinolva az Organization-el a nevekért
stmt = select(ServiceProfile, Organization).join(
Organization, ServiceProfile.organization_id == Organization.id
)
# 1. Sugár alapú szűrés (radius_km * 1000 méter)
stmt = stmt.where(
).where(
func.ST_DWithin(ServiceProfile.location, user_point, radius_km * 1000)
)
# 2. Szakterület szűrése
# SZAKÉRTELEM SZŰRÉS (Logic Preserved)
if expertise_key:
stmt = stmt.join(ServiceProfile.expertises).join(ExpertiseTag).where(
ExpertiseTag.key == expertise_key
)
# 3. Távolság és Trust Score alapú sorrend
# A ST_Distance méterben adja vissza az eredményt
# RENDEZÉS TÁVOLSÁG SZERINT
stmt = stmt.order_by(ST_Distance(ServiceProfile.location, user_point))
result = await db.execute(stmt.limit(50))
rows = result.all()
# Rangsorolási logika alkalmazása
results = []
for s_prof, org in rows:
results.append({
@@ -57,5 +51,5 @@ class SearchService:
"is_premium_partner": s_prof.trust_score >= 90
})
# Súlyozott rendezés: Prémium partnerek és Trust Score előre
# SÚLYOZOTT RENDEZÉS (Logic Preserved: Premium előre, Trust Score csökkenő)
return sorted(results, key=lambda x: (not is_premium, -x['trust_score']))