From 6a4a5c7eb8b608160d740cbb2a82def371bccc4b Mon Sep 17 00:00:00 2001
From: Eunhak Lee <lee@enak.kr>
Date: Mon, 9 Dec 2024 13:53:40 +0900
Subject: [PATCH] =?UTF-8?q?hotfix:=20combination=20=EC=9D=98=20=EC=A1=B4?=
 =?UTF-8?q?=EC=9E=AC=20=EC=97=AC=EB=B6=80=20=ED=99=95=EC=9D=B8=ED=95=A0=20?=
 =?UTF-8?q?=EB=95=8C=20part=20id=EB=8A=94=20=EC=A0=95=EB=A0=AC=EB=90=9C=20?=
 =?UTF-8?q?=EC=83=81=ED=83=9C=EC=97=AC=EC=95=BC=20=ED=95=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 push_to_db.py | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/push_to_db.py b/push_to_db.py
index 84293a1..8317991 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:
-- 
GitLab