diff --git a/push_to_db.py b/push_to_db.py index 84293a18ce68429bea734ddec66cc0f84626106a..8317991a8084bde252213789b7892def2f0ab21d 100644 --- a/push_to_db.py +++ b/push_to_db.py @@ -60,10 +60,6 @@ def handle_single_part(_dict, part_type): return None name = _dict["name"] - - if part_type == 'GPU': - name = name.replace("GeForce", "").replace("NVIDIA", "") - matched_parts = check_similarity(db_conn, name, part_type) if not matched_parts: @@ -102,7 +98,7 @@ def check_if_parts_exist(_cursor, _user_id, _part_ids): sql = """WITH result AS (SELECT combinations.id AS combination_id, ARRAY(SELECT part_id FROM relations WHERE relations.combination_id = combinations.id ORDER BY relations.part_id) AS parts FROM combinations WHERE combinations.owner_id = %s) SELECT combination_id FROM result WHERE parts = %s;""" - sql = _cursor.mogrify(sql, (_user_id, _part_ids)) + sql = _cursor.mogrify(sql, (_user_id, sorted(_part_ids))) logger.debug(sql) _cursor.execute(sql) data = _cursor.fetchall() @@ -220,13 +216,12 @@ def func(): _combination_id = None # 이미 존재하는 경우 - if not _created_parts: - logger.info("Checking combination existance") - with db_conn.cursor() as cursor: - _combination_id = check_if_parts_exist(cursor, _user_id, _part_ids) + logger.info("Checking combination existance") + with db_conn.cursor() as cursor: + _combination_id = check_if_parts_exist(cursor, _user_id, _part_ids) - if _combination_id is not None: - logger.info("Combination exist. Using combination id={}".format(_combination_id)) + if _combination_id is not None: + logger.info("Combination exist. Using combination id={}".format(_combination_id)) # 새로 추가하는 경우 if _combination_id is None: