Churchgate commited on
Commit
3bc5043
Β·
verified Β·
1 Parent(s): 8db0a88

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -3
app.py CHANGED
@@ -2541,7 +2541,6 @@ def page_ar():
2541
  st.markdown("### πŸ” Filters")
2542
  c1, c2, c3, c4 = st.columns(4)
2543
  with c1:
2544
- # Create dept_full for display BUT don't modify original df
2545
  df["dept_full"] = df.apply(lambda row: f"{row['department']} β€” {row['sub_division']}" if pd.notna(row.get('sub_division')) and row.get('sub_division') not in ['', 'N/A', 'NA'] else row['department'], axis=1)
2546
 
2547
  if is_admin:
@@ -2601,12 +2600,23 @@ def page_ar():
2601
  if len(ppm_df) > 0 and "next_due_date" in ppm_df.columns:
2602
  ppm_df["due_date_dt"] = pd.to_datetime(ppm_df["next_due_date"], errors='coerce')
2603
 
2604
- # Apply department filter - PRESERVES original department structure
2605
  if cal_dept != "All" and "assigned_team" in ppm_df.columns:
2606
- # Extract just the department part from cal_dept (before " β€” " if sub-division exists)
2607
  base_dept = cal_dept.split(" β€” ")[0] if " β€” " in cal_dept else cal_dept
2608
  ppm_df = ppm_df[ppm_df["assigned_team"].str.contains(base_dept, case=False, na=False)]
2609
 
 
 
 
 
 
 
 
 
 
 
 
 
2610
  ppm_dates = {}
2611
  if len(ppm_df) > 0 and "due_date_dt" in ppm_df.columns:
2612
  for _, row in ppm_df.iterrows():
@@ -2629,6 +2639,10 @@ def page_ar():
2629
  with c3: st.metric("πŸ“ Today", today_ppm)
2630
  with c4: st.metric("βœ… Completed", completed_ppm)
2631
 
 
 
 
 
2632
  st.markdown("---")
2633
 
2634
  # Build calendar HTML
 
2541
  st.markdown("### πŸ” Filters")
2542
  c1, c2, c3, c4 = st.columns(4)
2543
  with c1:
 
2544
  df["dept_full"] = df.apply(lambda row: f"{row['department']} β€” {row['sub_division']}" if pd.notna(row.get('sub_division')) and row.get('sub_division') not in ['', 'N/A', 'NA'] else row['department'], axis=1)
2545
 
2546
  if is_admin:
 
2600
  if len(ppm_df) > 0 and "next_due_date" in ppm_df.columns:
2601
  ppm_df["due_date_dt"] = pd.to_datetime(ppm_df["next_due_date"], errors='coerce')
2602
 
2603
+ # Apply department filter
2604
  if cal_dept != "All" and "assigned_team" in ppm_df.columns:
 
2605
  base_dept = cal_dept.split(" β€” ")[0] if " β€” " in cal_dept else cal_dept
2606
  ppm_df = ppm_df[ppm_df["assigned_team"].str.contains(base_dept, case=False, na=False)]
2607
 
2608
+ # Apply asset filter - compare as strings for UUID compatibility
2609
+ if cal_asset != "All" and "asset_id" in ppm_df.columns:
2610
+ asset_ids = df[df["parent_asset"] == cal_asset]["id"].astype(str).tolist()
2611
+ if asset_ids:
2612
+ ppm_df = ppm_df[ppm_df["asset_id"].astype(str).isin(asset_ids)]
2613
+
2614
+ # Apply building filter
2615
+ if cal_bldg != "All" and "asset_id" in ppm_df.columns:
2616
+ bldg_asset_ids = df[df["location_building"] == cal_bldg]["id"].astype(str).tolist()
2617
+ if bldg_asset_ids:
2618
+ ppm_df = ppm_df[ppm_df["asset_id"].astype(str).isin(bldg_asset_ids)]
2619
+
2620
  ppm_dates = {}
2621
  if len(ppm_df) > 0 and "due_date_dt" in ppm_df.columns:
2622
  for _, row in ppm_df.iterrows():
 
2639
  with c3: st.metric("πŸ“ Today", today_ppm)
2640
  with c4: st.metric("βœ… Completed", completed_ppm)
2641
 
2642
+ # Debug: show data range
2643
+ if len(ppm_df) > 0:
2644
+ st.caption(f"πŸ“‹ {len(ppm_df)} records loaded")
2645
+
2646
  st.markdown("---")
2647
 
2648
  # Build calendar HTML