QIDNLF commited on
Commit
fd60688
ยท
verified ยท
1 Parent(s): 936b57c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -12
app.py CHANGED
@@ -54,7 +54,6 @@ def fetch_available_standards():
54
  })
55
  return sorted(list(set([d["standard"] for d in db_registry])))
56
 
57
- # ๐Ÿ’ก [ํ•ต์‹ฌ ์ˆ˜์ •] ๋‹จ์ผ ์กฐํšŒ ์‹œ "์ „๋ถ€ ๋ณด์—ฌ์ฃผ๊ธฐ" ์œ„ํ•ด Display_Columns ํ•„ํ„ฐ๋ง ์กฑ์‡„๋ฅผ ์™„์ „ํžˆ ์ œ๊ฑฐํ–ˆ์Šต๋‹ˆ๋‹ค!
58
  def fetch_database_records(std, ver, cat, table_type):
59
  try:
60
  db_path = os.path.join(UPLOAD_DIR, f"{std}_{ver}.db")
@@ -101,7 +100,6 @@ def fetch_database_records(std, ver, cat, table_type):
101
  if matched_config is None:
102
  matched_config = config_df.iloc[0]
103
 
104
- # ๋ผˆ๋Œ€(Anchor)๋Š” ์ฐพ๋˜, ํ‘œ์‹œํ•  ์—ด(Display) ์ œํ•œ์€ ํ’€์—ˆ์Šต๋‹ˆ๋‹ค!
105
  anchors = [x.strip() for x in matched_config['Anchor_Column'].split(',')]
106
 
107
  query = f"SELECT * FROM [{main_table}]"
@@ -125,7 +123,11 @@ def fetch_database_records(std, ver, cat, table_type):
125
 
126
  real_anchors = [c for c in df.columns if any(a.lower() == c.lower() for a in anchors)]
127
 
128
- # ํ•„ํ„ฐ๋ง ์—†์ด DB ์›๋ณธ์˜ ๋ชจ๋“  ์—ด์„ ๋ทฐ์–ด์— ๋˜์ ธ์ค๋‹ˆ๋‹ค.
 
 
 
 
129
  for c in df.columns:
130
  df[c] = df[c].apply(convert_blob_to_html_img)
131
 
@@ -433,13 +435,11 @@ def execute_unified_search(base_std, base_ver, base_cat, comp_std, comp_ver, com
433
  else: new_cols.append(col)
434
  return df[new_cols]
435
 
436
- # ๐Ÿ’ก ๋‹จ์ผ ์กฐํšŒ ์‹œ: Table_Config ์ œํ•œ ์—†์ด ์žˆ๋Š” ๊ทธ๋Œ€๋กœ '์ „๋ถ€' ๋˜์ ธ์ค๋‹ˆ๋‹ค. (combine_code_desc ์ ์šฉ X)
437
  if base_std and base_ver and base_cat and (not comp_std or not comp_ver or not comp_cat):
438
  df, _ = fetch_database_records(base_std, base_ver, base_cat, type_b)
439
  if "Error" in df.columns: return df
440
  return apply_visual_merge(df, df.columns)
441
 
442
- # ๐Ÿ’ก ๋น„๊ต ์กฐํšŒ ์‹œ: combine_code_desc ํ•จ์ˆ˜๋ฅผ ์ ์šฉํ•˜์—ฌ _Code์™€ _Description์„ ํ•ฉ์นฉ๋‹ˆ๋‹ค.
443
  if all([base_std, base_ver, base_cat, comp_std, comp_ver, comp_cat]):
444
  df_base, real_anchors_b = fetch_database_records(base_std, base_ver, base_cat, type_b)
445
  df_comp, real_anchors_c = fetch_database_records(comp_std, comp_ver, comp_cat, type_c)
@@ -460,10 +460,13 @@ def execute_unified_search(base_std, base_ver, base_cat, comp_std, comp_ver, com
460
  s = s[:-2]
461
  return s.replace(" ", "")
462
 
 
 
 
 
463
  df_base['merge_key'] = df_base[real_anchors_b].apply(lambda row: '-'.join([clean_key_val(x) for x in row]), axis=1)
464
  df_comp['merge_key'] = df_comp[real_anchors_c].apply(lambda row: '-'.join([clean_key_val(x) for x in row]), axis=1)
465
 
466
- # ๐Ÿ’ก [1.o o, 2.o x, 3.x o ๋กœ์ง] ๊ฐ™์€ ๋ฒ•๊ทœ์ธ ๊ฒฝ์šฐ ํ•ฉ์ง‘ํ•ฉ(Union) ์ƒ์„ฑ
467
  is_same_std = (base_std.strip().upper() == comp_std.strip().upper() and type_b.strip().upper() == type_c.strip().upper())
468
 
469
  if is_same_std:
@@ -537,10 +540,7 @@ def execute_unified_search(base_std, base_ver, base_cat, comp_std, comp_ver, com
537
  else:
538
  bridge = pd.DataFrame(columns=['Base_section', 'Comp_section'])
539
 
540
- rename_b = {c: f"{c}_{base_ver}" for c in df_base.columns if c != 'merge_key'}
541
  df_base = df_base.rename(columns=rename_b)
542
-
543
- rename_c = {c: f"{c}_{comp_ver}" for c in df_comp.columns if c != 'merge_key'}
544
  df_comp = df_comp.rename(columns=rename_c)
545
 
546
  df_base['base_idx'], df_comp['comp_idx'] = range(len(df_base)), range(len(df_comp))
@@ -575,7 +575,6 @@ def execute_unified_search(base_std, base_ver, base_cat, comp_std, comp_ver, com
575
  row_dict[rename_b[orig_col]], row_dict[rename_c[orig_col]] = generate_html_diff(b_v, c_v)
576
  result_rows.append(row_dict)
577
 
578
- # ๐Ÿ’ก ๋น„๊ต ์กฐํšŒ ์‹œ ํ•ฉ์น˜๊ธฐ ํ•จ์ˆ˜(combine_code_desc) ์ ์šฉ!
579
  final_df = combine_code_desc(pd.DataFrame(result_rows))
580
 
581
  if final_df.empty:
@@ -587,8 +586,9 @@ def execute_unified_search(base_std, base_ver, base_cat, comp_std, comp_ver, com
587
  if final_df.empty:
588
  return pd.DataFrame({"Info": ["๐Ÿ’ก ์„ ํƒํ•˜์‹  ์กฐ๊ฑด ๊ฐ„์— ๋ณ€๊ฒฝ๋œ ๋‚ด์šฉ์ด ์—†์Šต๋‹ˆ๋‹ค. (100% ๋™์ผ)"]})
589
 
590
- b_cols_final = [c for c in final_df.columns if c.endswith(f"_{base_ver}")]
591
- c_cols_final = [c for c in final_df.columns if c.endswith(f"_{comp_ver}")]
 
592
 
593
  final_df = apply_visual_merge(final_df, b_cols_final)
594
  final_df = apply_visual_merge(final_df, c_cols_final)
 
54
  })
55
  return sorted(list(set([d["standard"] for d in db_registry])))
56
 
 
57
  def fetch_database_records(std, ver, cat, table_type):
58
  try:
59
  db_path = os.path.join(UPLOAD_DIR, f"{std}_{ver}.db")
 
100
  if matched_config is None:
101
  matched_config = config_df.iloc[0]
102
 
 
103
  anchors = [x.strip() for x in matched_config['Anchor_Column'].split(',')]
104
 
105
  query = f"SELECT * FROM [{main_table}]"
 
123
 
124
  real_anchors = [c for c in df.columns if any(a.lower() == c.lower() for a in anchors)]
125
 
126
+ # ๐Ÿ’ก [ํ•ต์‹ฌ ํ•ด๊ฒฐ] UI ํ…์ŠคํŠธ๋ฐ•์Šค์— Status๊ฐ€ ํ‘œ๊ธฐ๋˜๋ฏ€๋กœ, ์•„๋ž˜ ํ‘œ์—์„œ๋Š” Status ์—ด์„ ์‹น ์ง€์›Œ์ค๋‹ˆ๋‹ค.
127
+ status_cols = [c for c in df.columns if c.lower() == 'status']
128
+ if status_cols:
129
+ df = df.drop(columns=status_cols)
130
+
131
  for c in df.columns:
132
  df[c] = df[c].apply(convert_blob_to_html_img)
133
 
 
435
  else: new_cols.append(col)
436
  return df[new_cols]
437
 
 
438
  if base_std and base_ver and base_cat and (not comp_std or not comp_ver or not comp_cat):
439
  df, _ = fetch_database_records(base_std, base_ver, base_cat, type_b)
440
  if "Error" in df.columns: return df
441
  return apply_visual_merge(df, df.columns)
442
 
 
443
  if all([base_std, base_ver, base_cat, comp_std, comp_ver, comp_cat]):
444
  df_base, real_anchors_b = fetch_database_records(base_std, base_ver, base_cat, type_b)
445
  df_comp, real_anchors_c = fetch_database_records(comp_std, comp_ver, comp_cat, type_c)
 
460
  s = s[:-2]
461
  return s.replace(" ", "")
462
 
463
+ # ๐Ÿ’ก [ํ•ด๊ฒฐ 1] ๊ฐ™์€ ์ด๋ฆ„ ์ถฉ๋Œ ๋ฐฉ์ง€: ๋ณ‘ํ•ฉ ์ „ ๊ฐ๊ฐ (๊ธฐ์ค€), (๋น„๊ต) ํƒœ๊ทธ๋ฅผ ๋‹ฌ์•„์ค๋‹ˆ๋‹ค.
464
+ rename_b = {c: f"{c}_{base_ver}(๊ธฐ์ค€)" for c in df_base.columns if c != 'merge_key'}
465
+ rename_c = {c: f"{c}_{comp_ver}(๋น„๊ต)" for c in df_comp.columns if c != 'merge_key'}
466
+
467
  df_base['merge_key'] = df_base[real_anchors_b].apply(lambda row: '-'.join([clean_key_val(x) for x in row]), axis=1)
468
  df_comp['merge_key'] = df_comp[real_anchors_c].apply(lambda row: '-'.join([clean_key_val(x) for x in row]), axis=1)
469
 
 
470
  is_same_std = (base_std.strip().upper() == comp_std.strip().upper() and type_b.strip().upper() == type_c.strip().upper())
471
 
472
  if is_same_std:
 
540
  else:
541
  bridge = pd.DataFrame(columns=['Base_section', 'Comp_section'])
542
 
 
543
  df_base = df_base.rename(columns=rename_b)
 
 
544
  df_comp = df_comp.rename(columns=rename_c)
545
 
546
  df_base['base_idx'], df_comp['comp_idx'] = range(len(df_base)), range(len(df_comp))
 
575
  row_dict[rename_b[orig_col]], row_dict[rename_c[orig_col]] = generate_html_diff(b_v, c_v)
576
  result_rows.append(row_dict)
577
 
 
578
  final_df = combine_code_desc(pd.DataFrame(result_rows))
579
 
580
  if final_df.empty:
 
586
  if final_df.empty:
587
  return pd.DataFrame({"Info": ["๐Ÿ’ก ์„ ํƒํ•˜์‹  ์กฐ๊ฑด ๊ฐ„์— ๋ณ€๊ฒฝ๋œ ๋‚ด์šฉ์ด ์—†์Šต๋‹ˆ๋‹ค. (100% ๋™์ผ)"]})
588
 
589
+ # ๐Ÿ’ก [ํ•ด๊ฒฐ 1 ํ˜ธํ™˜] ์ƒˆ๋กญ๊ฒŒ ์ง€์ •ํ•œ (๊ธฐ๏ฟฝ๏ฟฝ), (๋น„๊ต) ํƒœ๊ทธ๋กœ ๋ณ‘ํ•ฉ ์…€ ์ฒ˜๋ฆฌ
590
+ b_cols_final = [c for c in final_df.columns if c.endswith(f"_{base_ver}(๊ธฐ์ค€)")]
591
+ c_cols_final = [c for c in final_df.columns if c.endswith(f"_{comp_ver}(๋น„๊ต)")]
592
 
593
  final_df = apply_visual_merge(final_df, b_cols_final)
594
  final_df = apply_visual_merge(final_df, c_cols_final)