File size: 3,292 Bytes
a95b240
 
 
 
 
 
9ca7e46
a95b240
 
 
 
 
 
9ca7e46
 
 
a95b240
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9ca7e46
a95b240
 
 
 
 
 
 
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
import pandas as pd
import streamlit as st
import csv
import io
import matplotlib.pyplot as plt
import numpy as np
from pre import preprocess_uploaded_file


def double_main(uploaded_file1,uploaded_file2):  
    # st.title('Single CSV Analyzer')

    if uploaded_file1 is not None and uploaded_file2 is not None:
        # Process the csv files with header
        data_1 = preprocess_uploaded_file(uploaded_file1)
        data_2 = preprocess_uploaded_file(uploaded_file2)
        if data_1['Start datetime'].min() < data_2['Start datetime'].min():
            older_df = data_1
            newer_df = data_2
        else:
            older_df = data_2
            newer_df = data_1

        older_df['Time spent'] = pd.to_datetime(older_df['Time spent'], unit='s').dt.strftime('%M:%S')
        newer_df['Time spent'] = pd.to_datetime(newer_df['Time spent'], unit='s').dt.strftime('%M:%S')

        older_datetime = older_df['Start datetime'].min() 
        newer_datetime = newer_df['Start datetime'].min() 
        st.write(f"The older csv started on {older_datetime}")
        st.write(f"The newer csv started on {newer_datetime}")

        # Merge dataframes on 'scenario name'
        merged_df = pd.merge(older_df, newer_df, on=['Functional area', 'Scenario name'], suffixes=('_old', '_new'))

        # Filter scenarios that were failing and are still failing
        fail_to_fail_scenarios = merged_df[(merged_df['Status_old'] == 'FAILED') & (merged_df['Status_new'] == 'FAILED')]

        st.markdown("### Consistent Failures(previously failing, now failing)")
        fail_count = len(fail_to_fail_scenarios)
        st.write(f"Failing scenarios Count: {fail_count}")
        # Select columns for display
        columns_to_display = ['Functional area', 'Scenario name', 'Error message_old', 'Error message_new']
        # Display the selected columns using st.write
        st.write(fail_to_fail_scenarios[columns_to_display])

        # Filter scenarios that were passing and now failing
        pass_to_fail_scenarios = merged_df[(merged_df['Status_old'] == 'PASSED') & (merged_df['Status_new'] == 'FAILED')]

        st.markdown("### New Failures(previously passing, now failing)")
        pass_fail_count = len(pass_to_fail_scenarios)
        st.write(f"Failing scenarios Count: {pass_fail_count}")
        # Select columns for display
        columns_to_display = ['Functional area', 'Scenario name', 'Error message_new', 'Time spent_old','Time spent_new',]
        # Display the selected columns using st.write
        st.write(pass_to_fail_scenarios[columns_to_display])

        # Filter scenarios that were failing and now passing
        fail_to_pass_scenarios = merged_df[(merged_df['Status_old'] == 'FAILED') & (merged_df['Status_new'] == 'PASSED')]

        # Display filtered dataframe in Streamlit app
        st.markdown("### New Failures(previously failing, now passing)")
        pass_count = len(fail_to_pass_scenarios)
        st.write(f"Passing scenarios Count: {pass_count}")
        # Select columns for display
        columns_to_display = ['Functional area', 'Scenario name', 'Error message_old', 'Time spent_old','Time spent_new',]
        # Display the selected columns using st.write
        st.write(fail_to_pass_scenarios[columns_to_display])
    pass