Beispiel #1
0
def profile_update(request):
    if request.method == 'POST':
        reqData = request.body.decode('utf8')
        reqData = json.loads(reqData)
        username = reqData['username']
        firstName = reqData['first_name']
        lastName = reqData['last_name']

        conn = getConnection()
        collection = conn['users']

        docs_list = list(collection.find({"username": username}))
        data = json.dumps(docs_list, default=json_util.default)
        data = json.loads(data)
        if data:
            if firstName is not None and lastName == "":
                cond = {"username": username}
                data = {"$set": {"first_name": reqData['first_name']}}
                if collection.update(cond, data):
                    return JsonResponse({
                        "reason": "Your Profile updated successfully.",
                        "message": "Success",
                        "data": data
                    })
            elif lastName is not None and firstName == "":
                cond = {"username": username}
                data = {"$set": {"last_name": reqData['last_name']}}
                if collection.update(cond, data):
                    return JsonResponse({
                        "reason": "Your Profile updated successfully.",
                        "message": "Success",
                        "data": data
                    })
            elif firstName is not None and lastName is not None:
                cond = {"username": username}
                data = {
                    "$set": {
                        "first_name": reqData['first_name'],
                        "last_name": reqData['last_name']
                    }
                }
                if collection.update(cond, data):
                    return JsonResponse({
                        "reason": "Your Profile updated successfully.",
                        "message": "Success",
                        "data": data
                    })

                else:
                    return JsonResponse({
                        "message": "Failure",
                    })

        else:
            return JsonResponse({
                "reason": "User email does not exist.",
                "message": "Failure"
            })
Beispiel #2
0
def login(request):
    if request.method == 'POST':
        reqData = request.body.decode('utf8')
        data = json.loads(reqData)

        # User input from FE during login.
        username = data['username']
        password = data['password']

        # mongoDB connection establishment
        conn = getConnection()
        collection = conn['users']

        docs_list = list(collection.find({'username': username}))
        data = json.dumps(docs_list, default=json_util.default)
        data = json.loads(data)

        # Check user exists or not.
        if data:
            if bcrypt.checkpw(password.encode('utf8'),
                              data[0]['password'].encode('utf8')):
                # docs_list = list(collection.find({'username': username, 'password': password}))
                # data = json.dumps(docs_list, default=json_util.default)
                # data = json.loads(data)
                statusdata = data[0]
                statusdata = statusdata["status"]
                if statusdata == "active":
                    return JsonResponse({
                        "reason": "User is active",
                        "message": "Success",
                        "data": data
                    })
                else:
                    return JsonResponse({
                        "reason":
                        "ACTIVATE your account by clicking on the verification URL sent to your email ID.",
                        "message": "Failure"
                    })
            # except ValueError as ve:
            return JsonResponse({
                "reason": "Incorrect Credentials",
                "message": "Failure"
            })
            # else:
            #     print(False)
            #     # return JsonResponse({
            #     #     "reason": "Incorrect Credentials",
            #     #     "message": "Failure"
            #     # })
        else:
            return JsonResponse({
                "reason": "User Does Not Exist",
                "message": "Failure"
            })
Beispiel #3
0
def success_trend_graph(request):
    conn = getConnection()
    # collection = conn['rpaInfo']
    collection = conn['rpaInfo']

    test_cycle_list = list(collection.distinct("Test Cycle #"))
    test_cycle_list = list(filter(None, test_cycle_list))
    actual_result_list = list(collection.distinct("Actual Result"))
    actual_result_list = list(filter(None, actual_result_list))
    final_test_cycle_list = []

    final = []
    for testCycle in test_cycle_list:
        final_test_cycle_list.append(round(testCycle))
        temp = {}
        pipe1 = [{
            '$match': {
                'Test Cycle #': testCycle
            }
        }, {
            '$count': 'Actual Result'
        }]
        actual_result_count = list(collection.aggregate(pipeline=pipe1))
        total = json.dumps(actual_result_count, default=json_util.default)
        total = json.loads(total)
        print(total)

        for actualResult in actual_result_list:
            pipe = [{
                '$match': {
                    'Test Cycle #': testCycle,
                    'Actual Result': actualResult
                }
            }, {
                '$count': 'Actual Result'
            }]
            doc_list = list(collection.aggregate(pipeline=pipe))
            dl = json.dumps(doc_list, default=json_util.default)
            dl = json.loads(dl)

            print('{} : testCycle {} count {}'.format(actualResult, testCycle,
                                                      dl))
            for data in dl:

                per = round((int(data['Actual Result']) /
                             (int(total[0]['Actual Result']))) * 100)
                temp[str(actualResult)] = per

        final.append(temp)
    print(final)
    data = dict(zip(final_test_cycle_list, final))
    return JsonResponse({"message": "success", "data": data})
Beispiel #4
0
def readRPAFile(request):
    wb = xlrd.open_workbook('RPA Execution Output.xlsx')
    # wb = xlrd.open_workbook('TestData.xlsx')
    # wb = xlrd.open_workbook('rpaInfo.xlsx')
    # wb = xlrd.open_workbook('result_2.xlsx')
    # wb = xlrd.open_workbook('RPA Execution Output.xlsx')
    sh = wb.sheet_by_name('Execution Details')
    # sh = wb.sheet_by_index(0)
    print(sh)
    # List to hold dictionaries
    r = list(sh.row(3))  # returns all the CELLS of row 3,
    print(r)
    column_name = []  # make a data store
    column_name.append(sh.row_values(3))
    print(column_name)
    data_list = []
    data = {}
    conn = getConnection()
    # conn.drop_collection('new_rpaInfo')
    # collection = conn['new_rpaInfo']
    collection = conn['rpaInfo']
    # collection.index_information()
    # print(len(columan_name[0]))
    # Iterate through each row in worksheet and fetch values into dict
    for rownum in range(4, sh.nrows):
        row_values = sh.row_values(rownum)
        for i in range(0, len(column_name[0])):
            # if row_values
            # if (columan_name[0][i] == 'Execution Date'):
            #     a1_as_datetime = datetime.datetime(*xlrd.xldate_as_tuple(row_values[i], wb.datemode))
            #     # print(a1_as_datetime)
            #     # data[columan_name[0][i]] = datetime.datetime.utcfromtimestamp(
            #     #     (row_values[i] - 25569) * 86400.0).strftime('%d-%m-%Y')
            #     continue
            data[column_name[0][i]] = row_values[i]
        # if data[column_name[0][1]] == 'Core HR':
        if data[column_name[0][1]]:
            # print(True)
            data_list.append(data.copy())
    # print(data_list)
    collection.insert_many(data_list)
    total_documents = collection.find().count()
    # data_list = json.dumps(data_list)

    return JsonResponse({
        "message": "success",
        "Total Rows": len(data_list),
        "Total Documents": total_documents
        # "data": data_list
    })
Beispiel #5
0
def excel_data(request):
    conn = getConnection()
    collection = conn['excelData']
    module_list = list(collection.distinct("Module"))
    final = []
    for i in module_list:
        dataList = list(
            collection.find({
                'Actual Result': 'Fail',
                'Module': i
            }, {"_id": 0}))
        data = json.dumps(dataList, default=json_util.default)
        data = json.loads(data)
        final.append(data)
    data = dict(zip(module_list, final))
    return JsonResponse({"message": "success", "data": final})
Beispiel #6
0
def reset_password(request):
    if request.method == 'POST':
        reqData = request.body.decode('utf8')
        data = json.loads(reqData)

        username = data['username']
        oldPassword = data['oldpassword']
        newPassword = data['newpassword']

        # mongoDB connection establishment
        conn = getConnection()
        collection = conn['users']

        docs_list = list(collection.find({'username': username}))
        data = json.dumps(docs_list, default=json_util.default)
        data = json.loads(data)

        if data:
            if bcrypt.checkpw(oldPassword.encode('utf8'),
                              data[0]['password'].encode('utf8')):
                if oldPassword != newPassword:
                    cond = {"username": username}
                    data = {
                        "$set": {
                            "password":
                            bcrypt.hashpw(newPassword.encode('utf8'),
                                          bcrypt.gensalt(14)).decode('utf-8')
                        }
                    }
                    # Update collection
                    if collection.update(cond, data):
                        return JsonResponse({
                            "message": "Success",
                            "username": username
                        })
                else:
                    return JsonResponse({
                        "message":
                        "Failure",
                        "reason":
                        "Current password and New Password Should be Different"
                    })
            else:
                return JsonResponse({
                    "message": "Failure",
                    "reason": "Current password is wrong"
                })
Beispiel #7
0
def update_table(request):
    if request.method == 'POST':
        reqData = request.body.decode('utf8')
        table_data = json.loads(reqData)

        # print(type(table_data)

        conn = getConnection()
        collection = conn['rpaInfo']

        for each_table_row in table_data:

            # print(each_table_row['SL #'])

            SL_NO = each_table_row['SL #']
            Severity = each_table_row['Severity']
            Details = each_table_row['Details']
            Status = each_table_row['Status']
            Defect_Owner = each_table_row['Defect Owner']

            docs_list = list(collection.find({'SL #': SL_NO}))
            data = json.dumps(docs_list, default=json_util.default)
            data = json.loads(data)

            if data:
                cond = {"SL #": SL_NO}
                data = {
                    "$set": {
                        "Severity": Severity,
                        "Details": Details,
                        "Status": Status,
                        "Defect Owner": Defect_Owner
                    }
                }

                collection.update(cond, data)

            else:
                return JsonResponse({
                    "reason": "Table Data not Found.",
                    "message": "Failure",
                })
        return JsonResponse({
            "reason": "Data Updated successfully",
            "message": "Success"
        })
Beispiel #8
0
def severity_by_cycle_by_modules(request):
    if request.method == 'GET':
        conn = getConnection()
        # collection = conn['rpaInfo']
        collection = conn['rpaInfo']

        module_list = list(collection.distinct("Module"))

        test_cycle_list = list(collection.distinct("Test Cycle #"))
        test_cycle_list = list(filter(None, test_cycle_list))

        final = []

        for module in module_list:
            final_data = {}
            for test_cycle in test_cycle_list:
                pipe = [{
                    '$match': {
                        'Module': module,
                        'Actual Result': 'Fail',
                        'Test Cycle #': test_cycle,
                        'Severity': {
                            '$ne': ''
                        }
                    }
                }, {
                    '$count': 'Severity'
                }]

                doc_list = list(collection.aggregate(pipeline=pipe))
                dl = json.dumps(doc_list, default=json_util.default)
                dl = json.loads(dl)

                for data in dl:
                    final_data[str(round(test_cycle))] = data['Severity']
            final.append(final_data)

        data = dict(zip(module_list, final))

        return JsonResponse({
            "message": "success",
            "Module": module_list,
            "data": data
        })
    else:
        return JsonResponse({"message": "HTTP method not allowed"})
Beispiel #9
0
def verify_user(request):
    username = request.GET['username']

    decryptUsername = decryption(username)
    # mongoDB connection establishment
    conn = getConnection()
    collection = conn['users']

    # Defining where and set condition for update
    cond = {"username": decryptUsername}
    data = {"$set": {"status": "active"}}
    try:
        if collection.update(cond, data):
            return render(request, 'verify_email.html')
    except TypeError as e:
        print(e)
    except ValueError as e:
        print(e)
Beispiel #10
0
def validate_email(request):
    if request.method == 'POST':
        reqData = request.body.decode('utf8')
        data = json.loads(reqData)
        username = data['username']

        # mongoDB connection establishment
        conn = getConnection()
        collection = conn['users']

        # Check whether user email exists or not
        docs_list = list(collection.find({'username': username}))

        data = json.dumps(docs_list, default=json_util.default)
        data = json.loads(data)
        if data:
            data = data[0]
            fullname = "{} {}".format(data["first_name"], data["last_name"])

            # Call send_email function to send email for password reset.
            subject = "Password Reset Link"
            message = """
            Dear {1},

            Please click on the below link to reset your password:

            https://quarkui.herokuapp.com/q_pawrd?username={0}

            Yours Truly,
            QUARK Support Team
            """.format(username, fullname)

            # Send email during forgot password
            # send_email(username , subject , message)
            test_email(username, subject, message)

            return JsonResponse({"message": "Success", "data": data})
        else:
            return JsonResponse({
                "reason": "Email not Found.",
                "message": "Failure"
            })
Beispiel #11
0
def read_file(request):
    wb = xlrd.open_workbook('TestData.xlsx')
    sh = wb.sheet_by_index(0)

    # List to hold dictionaries
    r = list(sh.row(0))  # returns all the CELLS of row 0,
    columan_name = []  # make a data store
    columan_name.append(sh.row_values(0))
    data_list = []
    data = {}
    conn = getConnection()
    collection = conn['testExcelData']

    # Iterate through each row in worksheet and fetch values into dict
    for rownum in range(1, sh.nrows):
        row_values = sh.row_values(rownum)
        for i in range(0, len(columan_name[0])):
            data[columan_name[0][i]] = row_values[i]
        data_list.append(data.copy())
    collection.insert_many(data_list.copy())

    return JsonResponse({
        "message": "success",
    })
Beispiel #12
0
def drill_down_DefectBySeverity(request):
    if request.method == 'GET':
        module = request.GET['module']
        conn = getConnection()
        # collection = conn['rpaInfo']
        collection = conn['rpaInfo']
        if module == 'Defect Management':
            dataList = list(
                collection.find(
                    {
                        'Expected Result': 'Pass',
                        'Actual Result': 'Fail'
                    }, {
                        'SL #': 1,
                        'Module': 1,
                        'Test Case ID': 1,
                        'Scenario ID': 1,
                        'Test Cycle #': 1,
                        'Defect No': 1,
                        'Log Date': 1,
                        'Severity': 1,
                        'Details': 1,
                        'Status': 1,
                        'Defect Owner': 1,
                        'Closing Date': 1,
                        '_id': 0
                    }))
            dataList = json.dumps(dataList, default=json_util.default)
            dataList = json.loads(dataList)
            if len(dataList) == 0:
                return JsonResponse({
                    "message":
                    "No Record Found for Module : {}".format(module),
                    "count":
                    len(dataList),
                })
            else:
                return JsonResponse({
                    "message": "success",
                    "count": len(dataList),
                    "data": dataList
                })
        else:
            dataList = list(
                collection.find(
                    {
                        'Module': module,
                        'Expected Result': 'Pass',
                        'Actual Result': 'Fail'
                    }, {
                        'SL #': 1,
                        'Module': 1,
                        'Test Case ID': 1,
                        'Scenario ID': 1,
                        'Test Cycle #': 1,
                        'Defect No': 1,
                        'Log Date': 1,
                        'Severity': 1,
                        'Details': 1,
                        'Status': 1,
                        'Defect Owner': 1,
                        'Closing Date': 1,
                        '_id': 0
                    }))
            dataList = json.dumps(dataList, default=json_util.default)
            dataList = json.loads(dataList)
            if len(dataList) == 0:
                return JsonResponse({
                    "message":
                    "No Record Found for Module : {}".format(module),
                    "count":
                    len(dataList),
                })
            else:
                return JsonResponse({
                    "message": "success",
                    "count": len(dataList),
                    "data": dataList
                })
    else:
        return JsonResponse(
            {"message": "HTTP {} method not allowed".format(request.method)})
Beispiel #13
0
def update_password(request):
    if request.method == 'POST':
        reqData = request.body.decode('utf8')
        data = json.loads(reqData)

        # User input during update password
        username = data['username']
        password = data['password']

        # mongoDB connection establishment
        conn = getConnection()
        collection = conn['users']

        docs_list = list(
            collection.find({'username': username}, {
                'password': 1,
                '_id': 0
            }))
        data = json.dumps(docs_list, default=json_util.default)
        data = json.loads(data)

        # if dbData[0]['password']!=password:

        #     # Defining where and set condition for update
        #     cond={
        #         "username" : username
        #     }
        #     data={
        #         "$set": {"password":password}
        #     }
        #     # Update collection
        #     if collection.update(cond,data):
        #         return JsonResponse({
        #             "message": "Success",
        #             "data": data
        #         })
        # else:
        #     return JsonResponse({
        #         "message": "Failure",
        #         "reason": "Your Password is same as Old Password.\nPlease choose a new one"
        #     })

        if bcrypt.checkpw(password.encode('utf8'),
                          data[0]['password'].encode('utf8')):
            return JsonResponse({
                "message":
                "Failure",
                "reason":
                "Your Password is same as Old Password.\nPlease choose a new one"
            })
        else:
            cond = {"username": username}
            data = {
                "$set": {
                    "password":
                    bcrypt.hashpw(password.encode('utf8'),
                                  bcrypt.gensalt(14)).decode('utf-8')
                }
            }

            # Update collection
            if collection.update(cond, data):
                return JsonResponse({"message": "Success", "data": data})
Beispiel #14
0
def signup(request):
    if request.method == 'POST':
        # print(request.body)
        reqData = request.body.decode('utf8')
        print(reqData)
        data = json.loads(reqData)

        # User input during signup
        data = {
            "first_name":
            data['first_name'],
            "last_name":
            data['last_name'],
            "username":
            data['username'],
            "password":
            bcrypt.hashpw(data['password'].encode('utf8'),
                          bcrypt.gensalt(14)).decode('utf-8'),
            # "password":data['password'],
            "roles":
            data['roles'],
            "status":
            "inactive"
        }

        print(data)

        # mongoDB connection establishment
        conn = getConnection()
        collection = conn['users']

        # Find if the User is Already Exists
        getData = collection.find({'username': data['username']})
        if (list(getData)):
            return JsonResponse({
                "reason": "User Already Exists",
                "message": "Failure"
            })

        # If the user is not exist, store to database.
        collection.insert_one(data)
        fullname = "{} {}".format(data['first_name'], data['last_name'])
        encUsername = encryption(data['username'])

        # Call send_email function to send email confirmation and account activation..
        subject = "Email Verification and Activation."
        message = """
        Dear {1},

        Please click on the below link for email verification and account activation:

        https://quarkapi.herokuapp.com/verify?username={0}

        Yours Truly,
        QUARK Support Team
        """.format(encUsername, fullname)

        # Send Email during user sign up.
        # send_email(data['username'], subject, message)
        test_email(data['username'], subject, message)

        # dumps: convert json to json string
        data = json.dumps(data, default=json_util.default)

        # loads: convert json string to json
        data = json.loads(data)
        return JsonResponse({"message": "Success", "data": data})
    return JsonResponse({
        "reason": "Requested method not allowed " + request.method,
        "message": "Failure"
    })
Beispiel #15
0
def infoTileDataDetails(request):
    if request.method == 'GET':
        result = request.GET['value']
        conn = getConnection()
        # collection = conn['rpaInfo']
        collection = conn['rpaInfo']
        # Distinct Modules List
        module_list = list(collection.distinct("Module"))
        execution_date_list = list(collection.distinct("Execution Date"))
        log_date_list = list(
            collection.distinct("Log Date", {"Log Date": {
                '$ne': ''
            }}))

        # Total Actual Count
        countActualResult = [{'$count': 'Actual Result'}]
        countActualResult = list(
            collection.aggregate(pipeline=countActualResult))

        if result == 'Test Case Status':
            # dataList = list(collection.find(
            #     {'Actual Result': "Pass"}, {'_id': 0, 'SL': 0, 'Failure Justification': 0,'Defect No':0
            #     ,"Log Date":0,"Severity":0,"Details":0,"Status":0,"Defect Owner":0,"Closing Date":0}))
            dataList = list(
                collection.find({'Actual Result': "Pass"}, {
                    '_id': 0,
                    'SL': 0
                }))
            return JsonResponse({
                "message": "success",
                "count": len(dataList),
                "data": dataList,
            })

        elif result == 'Defects Raised Velocity':
            dataList = list(
                collection.find({'Log Date': {
                    '$ne': ''
                }}, {
                    '_id': 0,
                    'SL': 0
                }))
            return JsonResponse({
                "message": "success",
                "count": len(dataList),
                "data": dataList
            })
        elif result == 'High Risk Module':
            dataList = []
            high_risk = 0
            high_risk_module_final = []
            for module in module_list:
                count = [{
                    '$match': {
                        'Actual Result': "Fail",
                        'Module': module
                    }
                }, {
                    '$count': 'Actual Result'
                }]
                high_risk_module = list(collection.aggregate(pipeline=count))

                if int(high_risk_module[0]['Actual Result']) > high_risk:
                    high_risk_module_final.clear()
                    high_risk = int(high_risk_module[0]['Actual Result'])
                    high_risk_module_final = list(
                        collection.find(
                            {
                                'Actual Result': "Fail",
                                'Module': module
                            }, {
                                '_id': 0,
                                'SL': 0
                            }))
            return JsonResponse({
                "message": "success",
                "count": len(high_risk_module_final),
                "data": high_risk_module_final
            })
        elif result == 'Test Case Velocity':
            dataList = list(
                collection.find({'Execution Date': {
                    '$ne': ''
                }}, {
                    '_id': 0,
                    'SL': 0
                }))
            return JsonResponse({
                "message": "success",
                "count": len(dataList),
                "data": dataList
            })
        elif result == 'High Severity Defects':
            dataList = list(
                collection.find({'Severity': 'High'}, {
                    '_id': 0,
                    'SL': 0
                }))
            dataListCritical = list(
                collection.find({'Severity': 'Critical'}, {
                    '_id': 0,
                    'SL': 0
                }))
            dataList.extend(dataListCritical)
            return JsonResponse({
                "message": "success",
                "count": len(dataList),
                "data": dataList
            })
        else:
            return JsonResponse({"message": "failed"})
    else:
        return JsonResponse({"message": "HTTP method not allowed"})
Beispiel #16
0
def infoTileData(request):
    if request.method == 'GET':
        conn = getConnection()
        # collection = conn['rpaInfo']
        collection = conn['rpaInfo']
        #Distinct Modules List
        module_list = list(collection.distinct("Module"))
        severity_list = list(collection.distinct('Severity'))
        severity_list = list(filter(None, severity_list))
        execution_date_list = list(collection.distinct("Execution Date"))
        # log_date_list=list(collection.distinct("Log Date" , { "Log Date" : { '$ne' : '' } } ))

        #Total Actual Count
        countActualResult = [{'$count': 'Actual Result'}]
        countActualResult = list(
            collection.aggregate(pipeline=countActualResult))

        #High risk Module (Module with most Failed cases)
        high_risk = 0
        high_risk_module_final = {}
        for module in module_list:
            count = [{
                '$match': {
                    'Actual Result': "Fail",
                    'Module': module
                }
            }, {
                '$count': 'Actual Result'
            }]
            high_risk_module = list(collection.aggregate(pipeline=count))
            if int(high_risk_module[0]['Actual Result']) > high_risk:
                high_risk = int(high_risk_module[0]['Actual Result'])
                high_risk_module_final[module] = high_risk

        #Test Case Status
        countPass = [{
            '$match': {
                'Actual Result': "Pass"
            }
        }, {
            '$count': 'Actual Result'
        }]
        countPass = list(collection.aggregate(pipeline=countPass))
        test_case_status = round(
            ((int(countPass[0]['Actual Result'])) /
             (int(countActualResult[0]['Actual Result'])) * 100), 1)

        # test_case_Velocity
        test_case_velocity = [{'$count': 'Test Case ID'}]
        test_case_velocity = list(
            collection.aggregate(pipeline=test_case_velocity))
        test_case_velocity = round(
            (int(test_case_velocity[0]['Test Case ID'])) /
            (len(execution_date_list)))

        #Defects Raised Velocity
        pipe = [{'$match': {'Log Date': {'$ne': ''}}}, {'$count': 'Log Date'}]
        total_count_log_date = list(collection.aggregate(pipeline=pipe))
        no_of_log_date = list(
            collection.distinct("Log Date", {"Log Date": {
                '$ne': ''
            }}))
        defects_raised_velocity = round(
            (int(total_count_log_date[0]['Log Date']) /
             (int(len(no_of_log_date)))), 1)

        # High Severity Defects
        high_severity_defects = 0
        if 'Critical' in severity_list and 'High' in severity_list:
            high_pipe = [{
                '$match': {
                    'Severity': 'High'
                }
            }, {
                '$count': 'Severity'
            }]
            critical_pipe = [{
                '$match': {
                    'Severity': 'Critical'
                }
            }, {
                '$count': 'Severity'
            }]

            high_count = list(collection.aggregate(pipeline=high_pipe))
            critical_count = list(collection.aggregate(pipeline=critical_pipe))

            high_severity_defects = (int(high_count[0]['Severity']) +
                                     int(critical_count[0]['Severity']))
        elif 'Critical' in severity_list:
            critical_pipe = [{
                '$match': {
                    'Severity': 'Critical'
                }
            }, {
                '$count': 'Severity'
            }]
            critical_count = list(collection.aggregate(pipeline=critical_pipe))

            high_severity_defects = (int(critical_count[0]['Severity']))
        elif 'High' in severity_list:
            high_pipe = [{
                '$match': {
                    'Severity': 'High'
                }
            }, {
                '$count': 'Severity'
            }]
            high_count = list(collection.aggregate(pipeline=high_pipe))

            high_severity_defects = (int(critical_count[0]['Severity']))

        return JsonResponse({
            "message": "success",
            "test_case_status": str(test_case_status) + '%',
            "test_case_velocity": test_case_velocity,
            "high_risk_module": high_risk_module_final,
            "defects_raised_velocity": defects_raised_velocity,
            "high_severity_defects": high_severity_defects
        })

    else:
        return JsonResponse({"message": "HTTP method not allowed"})
Beispiel #17
0
def show_graph(request):
    conn = getConnection()
    collection = conn['excelData']
    docs_list = list(
        collection.find({"Actual Result": "Fail"}, {
            "Module": 1,
            "Execution Date": 1,
            "Severity": 1,
            "_id": 0
        }))
    data = json.dumps(docs_list, default=json_util.default)
    data = json.loads(data)

    Execution_Date = []
    Core_HR = []
    Payroll = []
    Absence_Management = []
    Benefits = []
    Talent_Management = []
    LMS = []

    for ed in data:
        Execution_Date.append(ed['Execution Date'])
        # Execution_Date.append(
        #     datetime.datetime.utcfromtimestamp((ed['Execution Date'] - 25569) * 86400.0).strftime('%d-%m-%Y'))

    Execution_Date = sorted(
        Execution_Date,
        key=lambda i: datetime.datetime.strptime(i, '%d-%m-%Y'))
    print(Execution_Date)

    for i in data:

        if i['Module'] == 'Core HR' or i['Module'] == 'Payroll' or i['Module'] == 'Absence Management'\
            or i['Module'] == 'Benefits' or i['Module'] == 'Talent Management' or i['Module'] == 'LMS' :

            # Core HR
            pipe = [{
                '$match': {
                    'Module': 'Core HR'
                }
            }, {
                '$group': {
                    '_id': {
                        'Module': '$Module',
                        'Execution Date': '$Execution Date'
                    },
                    'Severity': {
                        '$sum': '$Severity'
                    }
                }
            }, {
                '$sort': {
                    '_id': 1
                }
            }]
            docs_list = list(collection.aggregate(pipeline=pipe))
            core_hr_data = json.dumps(docs_list, default=json_util.default)
            core_hr_data = json.loads(core_hr_data)

            # Payroll
            pipe = [{
                '$match': {
                    'Module': 'Payroll'
                }
            }, {
                '$group': {
                    '_id': {
                        'Module': '$Module',
                        'Execution Date': '$Execution Date'
                    },
                    'Severity': {
                        '$sum': '$Severity'
                    }
                }
            }, {
                '$sort': {
                    '_id': 1
                }
            }]
            docs_list = list(collection.aggregate(pipeline=pipe))
            payroll_data = json.dumps(docs_list, default=json_util.default)
            payroll_data = json.loads(payroll_data)

            # Absence Management
            pipe = [{
                '$match': {
                    'Module': 'Absence Management'
                }
            }, {
                '$group': {
                    '_id': {
                        'Module': '$Module',
                        'Execution Date': '$Execution Date'
                    },
                    'Severity': {
                        '$sum': '$Severity'
                    }
                }
            }, {
                '$sort': {
                    '_id': 1
                }
            }]
            docs_list = list(collection.aggregate(pipeline=pipe))
            absence_management_data = json.dumps(docs_list,
                                                 default=json_util.default)
            absence_management_data = json.loads(absence_management_data)

            # Benefits
            pipe = [{
                '$match': {
                    'Module': 'Benefits'
                }
            }, {
                '$group': {
                    '_id': {
                        'Module': '$Module',
                        'Execution Date': '$Execution Date'
                    },
                    'Severity': {
                        '$sum': '$Severity'
                    }
                }
            }, {
                '$sort': {
                    '_id': 1
                }
            }]
            docs_list = list(collection.aggregate(pipeline=pipe))
            benefits_data = json.dumps(docs_list, default=json_util.default)
            benefits_data = json.loads(benefits_data)

            # Talent Management
            pipe = [{
                '$match': {
                    'Module': 'Talent Management'
                }
            }, {
                '$group': {
                    '_id': {
                        'Module': '$Module',
                        'Execution Date': '$Execution Date'
                    },
                    'Severity': {
                        '$sum': '$Severity'
                    }
                }
            }, {
                '$sort': {
                    '_id': 1
                }
            }]
            docs_list = list(collection.aggregate(pipeline=pipe))
            talent_management_data = json.dumps(docs_list,
                                                default=json_util.default)
            talent_management_data = json.loads(talent_management_data)

            # LMS
            pipe = [{
                '$match': {
                    'Module': 'LMS'
                }
            }, {
                '$group': {
                    '_id': {
                        'Module': '$Module',
                        'Execution Date': '$Execution Date'
                    },
                    'Severity': {
                        '$sum': '$Severity'
                    }
                }
            }, {
                '$sort': {
                    '_id': 1
                }
            }]
            docs_list = list(collection.aggregate(pipeline=pipe))
            lms_data = json.dumps(docs_list, default=json_util.default)
            lms_data = json.loads(lms_data)

            # Core HR Severity
            for core_hr in core_hr_data:
                Core_HR.append(core_hr['Severity'])

            # Payroll Severity
            for payroll in payroll_data:
                Payroll.append(payroll['Severity'])

            # Absence Management Severity
            for absence_management in absence_management_data:
                Absence_Management.append(absence_management['Severity'])

            # Benefits Severity
            for benefits in benefits_data:
                Benefits.append(benefits['Severity'])

            # Talent Management
            for talent_management in talent_management_data:
                Talent_Management.append(talent_management['Severity'])

            # LMS
            for lms in lms_data:
                LMS.append(lms['Severity'])
            break

    # Create and style traces
    trace0 = go.Scatter(x=Execution_Date,
                        y=Absence_Management,
                        name='Absence Management',
                        line=dict(color=('rgb(244, 149, 66)')))
    trace1 = go.Scatter(x=Execution_Date,
                        y=Benefits,
                        name='Benefits',
                        line=dict(color=('rgb(226, 9, 9)')))
    trace2 = go.Scatter(x=Execution_Date,
                        y=Core_HR,
                        name='Core HR',
                        line=dict(color=('rgb(23, 140, 39)')))
    trace3 = go.Scatter(x=Execution_Date,
                        y=LMS,
                        name='LMS',
                        line=dict(color=('rgb(71, 24, 24)')))
    trace4 = go.Scatter(x=Execution_Date,
                        y=Payroll,
                        name='Payroll',
                        line=dict(color=('rgb(54, 4, 204)')))

    trace5 = go.Scatter(x=Execution_Date,
                        y=Talent_Management,
                        name='Talent Management',
                        line=dict(color=('rgb(4, 204, 127)')))
    data = [trace0, trace1, trace2, trace3, trace4, trace5]

    # Edit the layout
    layout = dict(
        title='DEFECT TRENDS',
        xaxis=dict(title='Execution Date'),
        yaxis=dict(title='Severity'),
    )

    fig = dict(data=data, layout=layout)
    plotly.offline.plot(fig, filename="line_graph.html")
    return JsonResponse({
        "message": "Success",
        'execution_date': Execution_Date,
        'core_hr': Core_HR,
        'absence_management': Absence_Management,
        'benefits': Benefits,
        'talent_management': Talent_Management,
        'lms': LMS
    })
Beispiel #18
0
def defects_by_severity(request):
    if request.method == 'GET':
        conn = getConnection()
        # collection = conn['rpaInfo']
        collection = conn['rpaInfo']
        module_list = list(collection.distinct("Module"))
        severity_list = list(collection.distinct("Severity"))
        severity_list = list(filter(None, severity_list))
        status_list = list(collection.distinct("Status"))
        status_list = list(filter(None, status_list))
        status_obj = {}
        # module_severities =[]
        module_severities = {}

        # Modified by Kedar
        # Data for Severity Count by Module
        total_severity_count_pipe = [{
            '$match': {
                'Severity': {
                    '$ne': ''
                }
            }
        }, {
            '$count': 'Total Severity Count'
        }]
        docs_total_severity_count_list = list(
            collection.aggregate(pipeline=total_severity_count_pipe))
        data_total_data_severity_count = json.dumps(
            docs_total_severity_count_list, default=json_util.default)
        data_total_data_severity_count = json.loads(
            data_total_data_severity_count)

        for module in module_list:
            finalData1 = {}

            final_obj = {}
            pipe_severity = [{
                '$match': {
                    'Module': module,
                    'Severity': {
                        '$ne': ''
                    }
                }
            }, {
                '$count': module
            }]
            docs_list = list(collection.aggregate(pipeline=pipe_severity))
            data_severity = json.dumps(docs_list, default=json_util.default)
            data_severity = json.loads(data_severity)

            # Modified by Kedar
            # Object of Severity Count by Modules
            for data in data_severity:
                for keys in data.keys():
                    # final_obj['module']=keys
                    final_obj['severity_count'] = data[module]
                    per = round((int(data[module]) /
                                 (int(data_total_data_severity_count[0]
                                      ['Total Severity Count']))) * 100)
                    final_obj['severity_count_%'] = per
            module_severities[keys] = final_obj

            for status in status_list:
                finalData = {}
                for severity in severity_list:
                    pipe = [{
                        '$match': {
                            'Module': module,
                            'Actual Result': 'Fail',
                            'Status': status,
                            'Severity': severity
                        }
                    }, {
                        '$count': severity
                    }]
                    doc_list = list(collection.aggregate(pipeline=pipe))
                    dl = json.dumps(doc_list, default=json_util.default)
                    dl = json.loads(dl)

                    for data in dl:
                        finalData[severity] = data[severity]
                finalData1[status] = finalData
            status_obj[module] = finalData1

        return JsonResponse({
            "message": "success",
            "data": status_obj,
            "result": module_severities
        })
    else:
        return JsonResponse({"message": "HTTP method not allowed"})
Beispiel #19
0
def drill_down_TestCases(request):
    if request.method == 'GET':
        result = request.GET['result']
        conn = getConnection()
        # collection = conn['rpaInfo']
        collection = conn['rpaInfo']
        if result == 'Test Case Management':
            dataList = list(
                collection.find({}, {
                    'SL #': 1,
                    'Module': 1,
                    'Test Case ID': 1,
                    'Scenario ID': 1,
                    'Test Cycle #': 1,
                    'Expected Result': 1,
                    'User': 1,
                    'Execution Date': 1,
                    'Actual Result': 1,
                    '_id': 0
                }))
            dataList = json.dumps(dataList, default=json_util.default)
            dataList = json.loads(dataList)
            if len(dataList) == 0:
                return JsonResponse({
                    "message":
                    "No Record Found for Module : {}".format(result),
                    "count":
                    len(dataList),
                })
            else:
                return JsonResponse({
                    "message": "success",
                    "count": len(dataList),
                    "data": dataList
                })
        else:
            dataList = list(
                collection.find({'Actual Result': result}, {
                    'SL #': 1,
                    'Module': 1,
                    'Test Case ID': 1,
                    'Scenario ID': 1,
                    'Test Cycle #': 1,
                    'Expected Result': 1,
                    'User': 1,
                    'Execution Date': 1,
                    'Actual Result': 1,
                    '_id': 0
                }))
            dataList = json.dumps(dataList, default=json_util.default)
            dataList = json.loads(dataList)
            if len(dataList) == 0:
                return JsonResponse({
                    "message":
                    "No Record Found for Module : {}".format(result),
                    "count":
                    len(dataList),
                })
            else:
                return JsonResponse({
                    "message": "success",
                    "count": len(dataList),
                    "data": dataList
                })
    else:
        return JsonResponse(
            {"message": "HTTP {} method not allowed".format(request.method)})