Skip to content

Commit

Permalink
# feat : Add price in ranking standard
Browse files Browse the repository at this point in the history
  • Loading branch information
hyein99 committed Jan 21, 2023
1 parent f98647a commit f949998
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ cython_debug/

# log file
*log
log*

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
Expand Down
32 changes: 17 additions & 15 deletions webserver/backend/app/recommend/rule_based.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@
def inference_gu(user_id, user_gu, db: Session):
s = f"""
SELECT H.house_id,
RANK() over (ORDER BY (SUM(G.infra_dist_score) + SUM(G.infra_cnt_score)) DESC, H.house_id) as ranking
FROM (SELECT MAX(house_id) as house_id, MAX(grid_id) as grid_id
FROM HOUSE_INFO2
WHERE sold_yn = 'N'
AND local2 = "{user_gu}"
GROUP BY latlng ) H,
RANK() over (ORDER BY (SUM(G.infra_dist_score) + SUM(G.infra_cnt_score)) DESC
, H.price_deposit
, H.price_monthly_rent
, H.house_id) as ranking
FROM HOUSE_INFO2 H,
GRID_SCORE G
WHERE H.grid_id = G.grid_id
AND H.sold_yn = 'N'
AND local2 = "{user_gu}"
AND G.INFRA_TYPE IN (SELECT U.infra_type
FROM USERS_INFRA U
where U.user_id = {user_id}
Expand All @@ -38,19 +39,20 @@ def inference_gu(user_id, user_gu, db: Session):
def inference_latlng(user_id, min_lat, max_lat, min_lng, max_lng, db: Session):
s = f"""
SELECT H.house_id,
RANK() over (ORDER BY (SUM(G.infra_dist_score) + SUM(G.infra_cnt_score)) DESC, H.house_id) as ranking
FROM (SELECT MAX(house_id) as house_id, MAX(grid_id) as grid_id
FROM HOUSE_INFO2
WHERE sold_yn = 'N'
AND ST_CONTAINS(ST_POLYFROMTEXT('POLYGON(({min_lng} {min_lat}
RANK() over (ORDER BY (SUM(G.infra_dist_score) + SUM(G.infra_cnt_score)) DESC
, H.price_deposit
, H.price_monthly_rent
, H.house_id) as ranking
FROM HOUSE_INFO2 H,
GRID_SCORE G
WHERE H.grid_id = G.grid_id
AND H.sold_yn = 'N'
AND ST_CONTAINS(ST_POLYFROMTEXT('POLYGON(({min_lng} {min_lat}
, {min_lng} {max_lat}
, {max_lng} {max_lat}
, {max_lng} {min_lat}
, {min_lng} {min_lat}))')
, latlng)
GROUP BY latlng ) H,
GRID_SCORE G
WHERE H.grid_id = G.grid_id
, H.latlng)
AND G.INFRA_TYPE IN (SELECT U.infra_type
FROM USERS_INFRA U
where U.user_id = {user_id}
Expand Down

0 comments on commit f949998

Please sign in to comment.