Update app.py
Browse files
app.py
CHANGED
|
@@ -425,10 +425,23 @@ def execute_unified_search(base_std, base_ver, base_cat, comp_std, comp_ver, com
|
|
| 425 |
df_comp['merge_key'] = df_comp[real_anchors_c].apply(lambda row: '-'.join(row.values.astype(str)), axis=1).str.replace(" ", "")
|
| 426 |
|
| 427 |
conn_map = sqlite3.connect(os.path.join(UPLOAD_DIR, "mapping.db"))
|
| 428 |
-
|
| 429 |
-
|
| 430 |
-
|
| 431 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 432 |
conn_map.close()
|
| 433 |
|
| 434 |
df_mapping = pd.concat([df_fw, df_rv], ignore_index=True)
|
|
@@ -441,7 +454,8 @@ def execute_unified_search(base_std, base_ver, base_cat, comp_std, comp_ver, com
|
|
| 441 |
else:
|
| 442 |
df_mapping = pd.DataFrame(columns=['Base_section', 'Comp_section'])
|
| 443 |
|
| 444 |
-
|
|
|
|
| 445 |
implicit = pd.DataFrame({'Base_section': list(set(df_base['merge_key']) & set(df_comp['merge_key'])),
|
| 446 |
'Comp_section': list(set(df_base['merge_key']) & set(df_comp['merge_key']))})
|
| 447 |
bridge = pd.concat([df_mapping, implicit], ignore_index=True).drop_duplicates()
|
|
|
|
| 425 |
df_comp['merge_key'] = df_comp[real_anchors_c].apply(lambda row: '-'.join(row.values.astype(str)), axis=1).str.replace(" ", "")
|
| 426 |
|
| 427 |
conn_map = sqlite3.connect(os.path.join(UPLOAD_DIR, "mapping.db"))
|
| 428 |
+
|
| 429 |
+
# DB์ Base_Type, Comp_Type ์ปฌ๋ผ์ด ์๋์ง ํ์ธ (์๋ฌ ๋ฐฉ์ง์ฉ)
|
| 430 |
+
map_cols = pd.read_sql("PRAGMA table_info(Mapping_table)", conn_map)['name'].tolist()
|
| 431 |
+
|
| 432 |
+
if 'Base_Type' in map_cols and 'Comp_Type' in map_cols:
|
| 433 |
+
q = "SELECT Base_section, Comp_section FROM Mapping_table WHERE TRIM(Base_std)=? AND TRIM(Base_ver)=? AND TRIM(Base_Type)=? AND TRIM(Comp_std)=? AND TRIM(Comp_ver)=? AND TRIM(Comp_Type)=?"
|
| 434 |
+
df_fw = pd.read_sql(q, conn_map, params=[base_std.strip(), base_ver.strip(), type_b, comp_std.strip(), comp_ver.strip(), type_c])
|
| 435 |
+
|
| 436 |
+
q_rv = "SELECT Comp_section AS Base_section, Base_section AS Comp_section FROM Mapping_table WHERE TRIM(Comp_std)=? AND TRIM(Comp_ver)=? AND TRIM(Comp_Type)=? AND TRIM(Base_std)=? AND TRIM(Base_ver)=? AND TRIM(Base_Type)=?"
|
| 437 |
+
df_rv = pd.read_sql(q_rv, conn_map, params=[base_std.strip(), base_ver.strip(), type_b, comp_std.strip(), comp_ver.strip(), type_c])
|
| 438 |
+
else:
|
| 439 |
+
# ๊ตฌ๋ฒ์ DB ํธํ์ฉ (Type ๋ฏธ๊ตฌ๋ถ)
|
| 440 |
+
q = "SELECT Base_section, Comp_section FROM Mapping_table WHERE TRIM(Base_std)=? AND TRIM(Base_ver)=? AND TRIM(Comp_std)=? AND TRIM(Comp_ver)=?"
|
| 441 |
+
df_fw = pd.read_sql(q, conn_map, params=[base_std.strip(), base_ver.strip(), comp_std.strip(), comp_ver.strip()])
|
| 442 |
+
q_rv = "SELECT Comp_section AS Base_section, Base_section AS Comp_section FROM Mapping_table WHERE TRIM(Comp_std)=? AND TRIM(Comp_ver)=? AND TRIM(Base_std)=? AND TRIM(Base_ver)=?"
|
| 443 |
+
df_rv = pd.read_sql(q_rv, conn_map, params=[base_std.strip(), base_ver.strip(), comp_std.strip(), comp_ver.strip()])
|
| 444 |
+
|
| 445 |
conn_map.close()
|
| 446 |
|
| 447 |
df_mapping = pd.concat([df_fw, df_rv], ignore_index=True)
|
|
|
|
| 454 |
else:
|
| 455 |
df_mapping = pd.DataFrame(columns=['Base_section', 'Comp_section'])
|
| 456 |
|
| 457 |
+
# [์์ ] ๊ฐ์ ๋ฒ๊ท & ๊ฐ์ ์นดํ
๊ณ ๋ฆฌ์ผ ๋๋ง ๋ฒํธ ์ผ์น ์๋ ๋งคํ ํ์ฉ
|
| 458 |
+
if base_std.strip().upper() == comp_std.strip().upper() and type_b == type_c:
|
| 459 |
implicit = pd.DataFrame({'Base_section': list(set(df_base['merge_key']) & set(df_comp['merge_key'])),
|
| 460 |
'Comp_section': list(set(df_base['merge_key']) & set(df_comp['merge_key']))})
|
| 461 |
bridge = pd.concat([df_mapping, implicit], ignore_index=True).drop_duplicates()
|