File size: 3,710 Bytes
cce2a89
 
 
 
245d859
 
 
cce2a89
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
245d859
 
 
 
cce2a89
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import pandas as pd
import sqlite3

def badges_get_pillar_dougnutdata():
    # con = sqlite3.connect("database.db")
    # df = pd.read_sql_query(f"SELECT * from badges", con)
    df = pd.read_csv("referencefiles/badges.csv")
    sdf = df.drop_duplicates()[['GUI', 'Pillar']]
    sdf = sdf[(sdf.Pillar.notna()) | (sdf.Pillar != 'null')]
    pillar_dist = sdf.groupby('Pillar').count().reset_index().rename(columns={'GUI':'cnt_gui'})
    sum_validrecords = pillar_dist.cnt_gui.sum()
    pillar_dist['pct_gui'] = pillar_dist['cnt_gui'] / sum_validrecords
    badges_pillar_doughnut_json = pillar_dist.to_json(orient='records')
    return badges_pillar_doughnut_json

def badges_get_badgecompletion_monthwise():
    df = pd.DataFrame(
                        {
                        'Month':['Nov-23', 'Dec-23', 'Jan-23', 'Feb-23', 'Mar-23', 'Apr-23', 'May-23', 'Jun-23'],
                        'cnt_gui_badgeinitiated':[45,40,30,56, 50,32,37,25],
                        'cnt_gui_badgeawarded':  [23,34,38,40, 31, 40,23,28],
                        },
                      )
    print(df)
    badgecompletion_monthwise_json = df.to_json(orient='records')
    return badgecompletion_monthwise_json

def get_validation_json(table_name, run_required=False):
    ## Dummy data for workforce
    # con = sqlite3.connect("database.db")
    # validation_df = pd.read_sql_query(f"SELECT * from {table_name}_validation", con)
    val_file_name = f"referencefiles/{table_name}_validation.csv"
    validation_df = pd.read_csv(val_file_name)
    json_data = validation_df.to_json(orient='records')
    return json_data

def get_wfrankwise_countmom(df=None):
    data = [
        ('Jan', 9, 15, 3, 30, 25, 23, 110),
        ('Feb', 7, 14, 2, 32, 40, 35, 106),
        ('Mar', 6, 13, 4, 36, 34, 20, 105),
        ('Apr', 8, 15, 3, 21, 30, 25, 112),
        ('May', 9, 19, 4, 25, 35, 30, 121),
        ('Jun', 7, 14, 3, 20, 25, 35, 113),
        ('Jul', 10, 11, 3, 41, 27, 25, 113)
    ]
    columns = ['Month', 'Director', 'Manager', 'Partner', 'Senior', 'SeniorManager', 'Staff', 'Grand Total']
    df = pd.DataFrame(data, columns=columns)
    json_df = df.to_json(orient='records')

    return json_df

def get_lst_topdepartment():
    lst_dept = [
        'D&A-BI&R-FS-GDS_S-BLR (138)',
        'D&A-BI&R-FS-GDS_NS-CCU (128)',
        'IntA-IntAut-NF-GDS_S-BLR (88)',
        'IntA-IntAut-NF-GDS_NS-GGN (75)',
        'D&A-BI&R-FS-GDS_NS-HYD (70)',
        'D&A-InMg-FS-GDS_S-BLR (70)',
        'INTA-INTAUT-NF (67)',
        'D&A-BI&R-FS-GDS_S-COK-L (59)',
        'D&A-BI&R-FS-GDS_S-MAA (58)',
        'D&A-InMg-NF-GDS_S-BLR (49)'
    ]
    return lst_dept

def get_wfrankwise_count():

    #write the logic to create pandas dataframe like below
    data = {
        "Rank": [
            "Contractor",
            "Director(Exec./Asst.)",
            "Manager",
            "null",
            "Senior",
            "Senior Manager",
            "Staff/Intern"
        ],
        "count_rank": [10, 10, 253, 322, 1391, 92, 1020]
    }

    df = pd.DataFrame(data)
    json_rankwise_count = df.to_json(orient='records')
    return json_rankwise_count


def get_topfive_badgetitle():
    lstbadges = [
        'Agile Learning Badge (479)',
        'Data Integration Bronze Badge (362)',
        'Data Integration Learning Badge (339)',
        'Data Visualization Bronze Badge (306)',
        'Data Visualization Learning Badge (295)',
        'Cloud Learning Badge (291)',
        'Robotic Process Automation Learning Badge (212)',
        'Robotic Process Automation Bronze Badge (191)',
        'Data Visualization Bronze Learning Badge (166)',
        'Data Science Learning Badge (165)'
    ]
    return lstbadges