Spaces:
Running
Running
poemsforaphrodite
commited on
Commit
•
89d1821
1
Parent(s):
24aff0c
Update app.py
Browse files
app.py
CHANGED
@@ -420,6 +420,34 @@ def show_model_type_selector():
|
|
420 |
key='model_type_selector'
|
421 |
)
|
422 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
423 |
def show_date_range_selector():
|
424 |
logging.info("Showing date range selector")
|
425 |
return st.selectbox(
|
@@ -565,20 +593,13 @@ def main():
|
|
565 |
logger.info("Calculating relevancy scores for all rows")
|
566 |
st.session_state.report_data = calculate_relevancy_scores(st.session_state.report_data, model_type)
|
567 |
|
568 |
-
|
569 |
-
logger.debug(f"Processing row {index}: Query: {row['query']}, Page: {row['page']}")
|
570 |
-
st.write(f"Query: {row['query']}")
|
571 |
-
st.write(f"Page: {row['page']}")
|
572 |
-
st.write(f"Relevancy Score: {row['relevancy_score']:.4f}")
|
573 |
-
show_competitor_analysis(row, co)
|
574 |
-
st.divider()
|
575 |
|
576 |
download_csv_link(st.session_state.report_data)
|
577 |
elif st.session_state.report_data is not None:
|
578 |
logger.warning("No data found for the selected criteria.")
|
579 |
st.warning("No data found for the selected criteria.")
|
580 |
|
581 |
-
|
582 |
if __name__ == "__main__":
|
583 |
logging.info("Running main function")
|
584 |
main()
|
|
|
420 |
key='model_type_selector'
|
421 |
)
|
422 |
|
423 |
+
def show_tabular_data(df, co):
|
424 |
+
st.write("Data Table with Relevancy Scores and Competitor Analysis")
|
425 |
+
|
426 |
+
for index, row in df.iterrows():
|
427 |
+
with st.expander(f"Query: {row['query']} | Page: {row['page']}"):
|
428 |
+
col1, col2 = st.columns(2)
|
429 |
+
|
430 |
+
with col1:
|
431 |
+
st.write("GSC Data:")
|
432 |
+
st.write(f"URL: {row['page']}")
|
433 |
+
st.write(f"Query: {row['query']}")
|
434 |
+
st.write(f"Impressions: {row['impressions']}")
|
435 |
+
st.write(f"Clicks: {row['clicks']}")
|
436 |
+
st.write(f"Position: {row['position']}")
|
437 |
+
st.write(f"Relevancy Score: {row['relevancy_score']:.4f}")
|
438 |
+
|
439 |
+
with col2:
|
440 |
+
st.write("Competitor Analysis:")
|
441 |
+
if st.button("Analyze Competitors", key=f"comp_{index}"):
|
442 |
+
with st.spinner('Analyzing competitors...'):
|
443 |
+
results_df = analyze_competitors(row, co)
|
444 |
+
st.dataframe(results_df)
|
445 |
+
|
446 |
+
our_rank = results_df.index[results_df['url'] == row['page']].tolist()[0] + 1
|
447 |
+
st.write(f"Our page ranks {our_rank} out of {len(results_df)} in terms of relevancy score.")
|
448 |
+
|
449 |
+
|
450 |
+
|
451 |
def show_date_range_selector():
|
452 |
logging.info("Showing date range selector")
|
453 |
return st.selectbox(
|
|
|
593 |
logger.info("Calculating relevancy scores for all rows")
|
594 |
st.session_state.report_data = calculate_relevancy_scores(st.session_state.report_data, model_type)
|
595 |
|
596 |
+
show_tabular_data(st.session_state.report_data, co)
|
|
|
|
|
|
|
|
|
|
|
|
|
597 |
|
598 |
download_csv_link(st.session_state.report_data)
|
599 |
elif st.session_state.report_data is not None:
|
600 |
logger.warning("No data found for the selected criteria.")
|
601 |
st.warning("No data found for the selected criteria.")
|
602 |
|
|
|
603 |
if __name__ == "__main__":
|
604 |
logging.info("Running main function")
|
605 |
main()
|