Merge pull request 'fix(tradein): estimate 500 — алиас distance_m в ORDER BY' (#388) from fix/tradein-estimate-orderby-alias into main
This commit is contained in:
commit
137c8bbb08
1 changed files with 4 additions and 1 deletions
|
|
@ -343,7 +343,10 @@ def _fetch_analogs(
|
|||
AND scraped_at > NOW() - (:fresh_days || ' days')::interval
|
||||
AND price_rub > 0
|
||||
ORDER BY (
|
||||
distance_m / 1000.0
|
||||
-- distance_m — это SELECT-алиас. В ORDER BY-ВЫРАЖЕНИИ (не голым
|
||||
-- термом) PostgreSQL трактует имя как входную колонку listings,
|
||||
-- которой нет → "column distance_m does not exist". Инлайним ST_Distance.
|
||||
ST_Distance(geom::geography, ST_MakePoint(:lon, :lat)::geography) / 1000.0
|
||||
+ CASE WHEN :target_year IS NOT NULL AND year_built IS NOT NULL
|
||||
THEN abs(year_built - :target_year) / 12.0 ELSE 0 END
|
||||
+ CASE WHEN :target_house_type IS NOT NULL AND house_type IS NOT NULL
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue