poemsforaphrodite commited on
Commit
4f7f1e3
1 Parent(s): 42a9dff

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -24
app.py CHANGED
@@ -664,16 +664,18 @@ def show_tabular_data(df, co, country_code):
664
 
665
  # Competitors column
666
  if not pd.isna(row.relevancy_score) and row.relevancy_score != 0:
667
- competitor_key = f"comp_{i}"
668
- compare_key = f"compare_{i}"
 
 
669
 
670
- if competitor_key not in st.session_state:
671
- st.session_state[competitor_key] = False
672
 
673
- if st.button("Show", key=competitor_key):
674
- st.session_state[competitor_key] = True
675
 
676
- if st.session_state[competitor_key]:
677
  st.write(f"Competitor Analysis for: {row.query}")
678
  with st.spinner('Analyzing competitors...'):
679
  results_df = analyze_competitors(row._asdict(), co, country_code=country_code)
@@ -717,25 +719,13 @@ def show_tabular_data(df, co, country_code):
717
  else:
718
  st.error(f"Our page '{row.page}' is not in the results. This indicates an error in fetching or processing the page.")
719
 
720
- # Add "Compare" button at the bottom of the competitors table
721
- st.markdown(
722
- """
723
- <style>
724
- .stButton > button {
725
- background-color: #008CBA;
726
- color: white;
727
- }
728
- </style>
729
- """,
730
- unsafe_allow_html=True
731
- )
732
- if compare_key not in st.session_state:
733
- st.session_state[compare_key] = False
734
 
735
- if st.button("Compare Your Relevancy Score to the Page In First Place", key=compare_key):
736
- st.session_state[compare_key] = True
737
 
738
- if st.session_state[compare_key]:
739
  compare_with_top_result(row._asdict(), co, country_code)
740
  else:
741
  cols[8].write("N/A")
 
664
 
665
  # Competitors column
666
  if not pd.isna(row.relevancy_score) and row.relevancy_score != 0:
667
+ competitor_state_key = f"comp_state_{i}"
668
+ competitor_button_key = f"comp_button_{i}"
669
+ compare_state_key = f"compare_state_{i}"
670
+ compare_button_key = f"compare_button_{i}"
671
 
672
+ if competitor_state_key not in st.session_state:
673
+ st.session_state[competitor_state_key] = False
674
 
675
+ if cols[8].button("Show", key=competitor_button_key):
676
+ st.session_state[competitor_state_key] = True
677
 
678
+ if st.session_state[competitor_state_key]:
679
  st.write(f"Competitor Analysis for: {row.query}")
680
  with st.spinner('Analyzing competitors...'):
681
  results_df = analyze_competitors(row._asdict(), co, country_code=country_code)
 
719
  else:
720
  st.error(f"Our page '{row.page}' is not in the results. This indicates an error in fetching or processing the page.")
721
 
722
+ if compare_state_key not in st.session_state:
723
+ st.session_state[compare_state_key] = False
 
 
 
 
 
 
 
 
 
 
 
 
724
 
725
+ if st.button("Compare Your Relevancy Score to the Page In First Place", key=compare_button_key):
726
+ st.session_state[compare_state_key] = True
727
 
728
+ if st.session_state[compare_state_key]:
729
  compare_with_top_result(row._asdict(), co, country_code)
730
  else:
731
  cols[8].write("N/A")