File size: 3,575 Bytes
13a5750
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e577a2e
13a5750
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import pandas as pd
import plotly.express as px
import streamlit as st

from process_kpi.process_wbts_capacity import WbtsCapacity, load_data
from utils.convert_to_excel import convert_dfs

# Streamlit UI

st.title(" 📊 WBTS Capacity Analysis")
doc_col, image_col = st.columns(2)

with doc_col:
    st.write(
        """This app allows you to analyze the capacity of WBTSs in a network. 
        It provides insights into the utilization of BB and CE resources, 
        helping you identify potential capacity issues and plan for upgrades.
        
        The report should be run with a minimum of 3 days of data.
        - Daily Aggregated
        - WBTS level
        - Exported in CSV format.
        """
    )

with image_col:
    st.image("./assets/wbts_capacity.png", width=400)

uploaded_file = st.file_uploader(
    "Upload WBTS capacity report in CSV format", type="csv"
)

col1, col2, col3 = st.columns(3)

if uploaded_file is not None:
    WbtsCapacity.final_results = None
    with col1:
        num_days = st.number_input(
            "Number of days for analysis",
            min_value=3,
            max_value=30,
            value=7,
        )
    with col2:
        number_of_threshold_days = st.number_input(
            "Number of days for threshold",
            min_value=1,
            max_value=30,
            value=3,
        )
    with col3:
        threshold = st.number_input("Threshold", min_value=1, max_value=100, value=80)

    if st.button("Analyze Data", type="primary"):
        try:
            df = load_data(uploaded_file, num_days, threshold, number_of_threshold_days)
            WbtsCapacity.final_results = convert_dfs([df], ["WBTS_Analysis"])

            if WbtsCapacity.final_results is not None:
                st.download_button(
                    on_click="ignore",
                    type="primary",
                    label="Download the Analysis Report",
                    data=WbtsCapacity.final_results,
                    file_name="WBTS_Analysis_Report.xlsx",
                    mime="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
                )
            st.write(df)
            # BB comments analysis and visualization
            bb_comments_df = df["bb_comments"].value_counts().reset_index()
            bb_comments_df.columns = ["bb_comments", "count"]

            bb_col1, bb_col2 = st.columns(2)
            with bb_col1:
                st.write(bb_comments_df)

            # BB comments chart
            fig = px.bar(
                bb_comments_df,
                x="bb_comments",
                y="count",
                title="BB Comments Distribution",
            )
            fig.update_traces(texttemplate="%{value}", textposition="outside")
            with bb_col2:
                st.plotly_chart(fig)

            # CE comments analysis and visualization
            ce_comments_df = df["ce_comments"].value_counts().reset_index()
            ce_comments_df.columns = ["ce_comments", "count"]

            ce_col1, ce_col2 = st.columns(2)
            with ce_col1:
                st.write(ce_comments_df)

            # CE comments chart
            fig = px.bar(
                ce_comments_df,
                x="ce_comments",
                y="count",
                title="CE Comments Distribution",
            )
            fig.update_traces(texttemplate="%{value}", textposition="outside")
            with ce_col2:
                st.plotly_chart(fig)
        except Exception as e:
            st.error(f"An error occurred. Error: {e}")