Skip to content

Commit 6298a0c

Browse files
authored
[issue 108] 축제 용 crawler 기능 prod 배포 (#110)
* feat/108-festival-delete * lint * feat-108 crawler deletion * black lint * review 반영 * lint
1 parent 441ebab commit 6298a0c

File tree

1 file changed

+27
-7
lines changed

1 file changed

+27
-7
lines changed

handler.py

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,34 @@ def menus_transaction(crawled_meals, cursor):
113113
db_menus = cursor.fetchall()
114114
new_menus, deleted_menus, edited_menus = compare_menus(db_menus, crawled_meals, restaurants)
115115

116+
# 원본 코드
117+
# if deleted_menus:
118+
# deleted_menus_id = [str(menu.get("id")) for menu in deleted_menus]
119+
# delete_menus_query = f"""
120+
# DELETE FROM menu
121+
# WHERE id in ({','.join(deleted_menus_id)});
122+
# """
123+
# cursor.execute(delete_menus_query)
124+
# send_deleted_menus_message(deleted_menus)
125+
#
126+
127+
# 축제용 수정된 코드 (prod 전용)
128+
# 축제 기간 (5/13 ~ 5/15) 종료 후 삭제
116129
if deleted_menus:
117-
deleted_menus_id = [str(menu.get("id")) for menu in deleted_menus]
118-
delete_menus_query = f"""
119-
DELETE FROM menu
120-
WHERE id in ({','.join(deleted_menus_id)});
121-
"""
122-
cursor.execute(delete_menus_query)
123-
send_deleted_menus_message(deleted_menus)
130+
deleted_menus_id = []
131+
for menu in deleted_menus:
132+
restaurant_id = menu.get("restaurant_id")
133+
if restaurant_id >= 235 and restaurant_id <= 249:
134+
continue
135+
deleted_menus_id.append(str(menu.get("id")))
136+
137+
if deleted_menus_id:
138+
delete_menus_query = f"""
139+
DELETE FROM menu
140+
WHERE id in ({','.join(deleted_menus_id)});
141+
"""
142+
cursor.execute(delete_menus_query)
143+
send_deleted_menus_message(deleted_menus)
124144

125145
insert_menus_query = """
126146
INSERT INTO menu(restaurant_id, code, date, type, name_kr, price, etc)

0 commit comments

Comments
 (0)