コード例 #1
0
ファイル: views.py プロジェクト: MingquanLiang/logManager
def figureResult(userParameter):
    """ This function: 1) Get user's online submission ; 2) Get and filter data from database 3) display as figure """


    testType = userParameter['testType']
    testItem = userParameter['testItem']
    startTime = userParameter['startTime']
    endTime = userParameter['endTime']


    allSIObject = filterDataFromDatabase(testType, startTime, endTime)
    assert allSIObject != None, 'Failed To filter data, Please check user submission: testType=[%s], testItem=[%s], startTime=[%s], endTime=[%s]' % (testType, testItem, startTime, endTime)

    allSIObjectList = []
    allItems = reverseGetAllFieldsMap(getAllFieldsMap(SI, getAll=False))
    for siObject in allSIObject:
        siObjectMap = {}
        testItemName = allItems[testItem]
        ### *** field from SI(id is primary key and testResult_id is foreign key, and can refer to SR via testResult) ***
        id = siObject.id
        #testResult_id = siObject.testResult_id
        testResult = siObject.testResult
        value = getattr(siObject, testItemName)
        if value == FLOATDEFAULT:
            continue
        testSoftware = siObject.testSoftware
        testConfiguration = siObject.testConfiguration

        ### it is a <type 'datetime.datetime'> object
        testTime = siObject.testTime
        year = testTime.year
        ### *** attention, when pass into Html, month should be minus 1 ***
        month = int(testTime.month) - 1 
        day = testTime.day
        hour = testTime.hour
        minute = testTime.minute
        second = testTime.second

        ### *** field from SR by foreign key: testResult_id is the foreign key of SI reference on SR(its primary key is id) ***
        testUser = testResult.testUser
        testComment = testResult.testComment
        #testRecordTime = testResult.testRecordTime
        testResultDetailLink = testResult.testResultDetailLink

        siObjectMap = { 'id': id, 'value': value, 'testSoftware': testSoftware, 'testConfiguration': testConfiguration, \
                        'year': year, 'month': month, 'day': day, 'hour': hour, 'minute': minute, 'second': second, \
                        'testUser': testUser, 'testComment': testComment, 'testResultDetailLink':testResultDetailLink }
        allSIObjectList.append(siObjectMap)
    testResultLength = len(allSIObjectList)

    parseParameter = {}
    parseParameter['testType'] = testType
    parseParameter['testItem'] = testItem
    parseParameter['allSIObjectList'] = allSIObjectList
    parseParameter['testResultLength'] = testResultLength
    parseParameter['STATIC_URL'] = STATIC_URL

    return render_to_response('demo_application/search/figure_result.html', parseParameter)
コード例 #2
0
def figureResult(userParameter):
    """ This function: 1) Get user's online submission ; 2) Get and filter data from database 3) display as figure """

    testType = userParameter['testType']
    testItem = userParameter['testItem']
    startTime = userParameter['startTime']
    endTime = userParameter['endTime']

    allSIObject = filterDataFromDatabase(testType, startTime, endTime)
    assert allSIObject != None, 'Failed To filter data, Please check user submission: testType=[%s], testItem=[%s], startTime=[%s], endTime=[%s]' % (
        testType, testItem, startTime, endTime)

    allSIObjectList = []
    allItems = reverseGetAllFieldsMap(getAllFieldsMap(SI, getAll=False))
    for siObject in allSIObject:
        siObjectMap = {}
        testItemName = allItems[testItem]
        ### *** field from SI(id is primary key and testResult_id is foreign key, and can refer to SR via testResult) ***
        id = siObject.id
        #testResult_id = siObject.testResult_id
        testResult = siObject.testResult
        value = getattr(siObject, testItemName)
        if value == FLOATDEFAULT:
            continue
        testSoftware = siObject.testSoftware
        testConfiguration = siObject.testConfiguration

        ### it is a <type 'datetime.datetime'> object
        testTime = siObject.testTime
        year = testTime.year
        ### *** attention, when pass into Html, month should be minus 1 ***
        month = int(testTime.month) - 1
        day = testTime.day
        hour = testTime.hour
        minute = testTime.minute
        second = testTime.second

        ### *** field from SR by foreign key: testResult_id is the foreign key of SI reference on SR(its primary key is id) ***
        testUser = testResult.testUser
        testComment = testResult.testComment
        #testRecordTime = testResult.testRecordTime
        testResultDetailLink = testResult.testResultDetailLink

        siObjectMap = { 'id': id, 'value': value, 'testSoftware': testSoftware, 'testConfiguration': testConfiguration, \
                        'year': year, 'month': month, 'day': day, 'hour': hour, 'minute': minute, 'second': second, \
                        'testUser': testUser, 'testComment': testComment, 'testResultDetailLink':testResultDetailLink }
        allSIObjectList.append(siObjectMap)
    testResultLength = len(allSIObjectList)

    parseParameter = {}
    parseParameter['testType'] = testType
    parseParameter['testItem'] = testItem
    parseParameter['allSIObjectList'] = allSIObjectList
    parseParameter['testResultLength'] = testResultLength
    parseParameter['STATIC_URL'] = STATIC_URL

    return render_to_response('demo_application/search/figure_result.html',
                              parseParameter)
コード例 #3
0
ファイル: views.py プロジェクト: MingquanLiang/logManager
def tableResult(userParameter):
    """ This function: 1) Get user's online submission ; 2) Get and filter data from database 3) display as table """

    testType = userParameter['testType']
    testItem = userParameter['testItem']
    startTime = userParameter['startTime']
    endTime = userParameter['endTime']


    allSIObject = filterDataFromDatabase(testType, startTime, endTime)
    assert allSIObject != None, 'Failed To filter data, Please check user submission: testType=[%s], testItem=[%s], startTime=[%s], endTime=[%s]' % (testType, testItem, startTime, endTime)

    if len(allSIObject) == 0:
        parseParameter = {}
        parseParameter['testType'] = testType
        parseParameter['testItem'] = testItem
        parseParameter['no_data'] = 'no_data'
        parseParameter['STATIC_URL'] = STATIC_URL
        return render_to_response('demo_application/search/table_result.html', parseParameter)

    testResult = {}
    allItems = reverseGetAllFieldsMap(getAllFieldsMap(SI, getAll=False))
    for i in allSIObject:
        testItemName = allItems[testItem]
        #testResult[(i.testSoftware, i.testConfiguration)] = getattr(i, testItemName) # show horizontally
        testResult[(i.testConfiguration, i.testSoftware)] = getattr(i, testItemName)  # show vertically
    testRow = list(set([i[0] for i in testResult]))
    testColumn = list(set([i[1] for i in testResult]))
    testValue = []
    for everyRow in testRow:
        #testValue.append([testResult.get((everyRow, everyColumn), '-') for everyColumn in testColumn])
        tempList = []
        for everyColumn in testColumn:
            value = testResult.get((everyRow, everyColumn), '-')
            if value == FLOATDEFAULT:
                value = '-'
            tempList.append(value)
        testValue.append(tempList)

    columnLength = len(testColumn)
    if CODEDEBUG == True:
        Color_Print('green', 'Row is [%s] and Column is [%s] and Value is [%s]' % (testRow, testColumn, testValue))
        Color_Print('green', 'Value is [%s]' % testValue)

    assert len(testRow) == len(testValue), 'testRow is [%s] and testValue is [%s]' % (testRow, testValue)
    #if len(testRow) != len(testValue):
    #    return render_to_response('demo_application/search/search_error.html', {})

    testRowAndValueList = []
    for index in range(len(testRow)):
        testRowAndValueList += [testRow[index]] + testValue[index]
    testRowIndexList = [index for index in range(len(testRowAndValueList)) if testRowAndValueList[index] in testRow ]
    testValueIndexList = []
    for i in testRowIndexList:
        testValueIndexList.append(int(i) + len(testValue[0]))

    parseParameter = {}
    parseParameter['testResult'] = testResult
    parseParameter['testType'] = testType
    parseParameter['testItem'] = testItem
    parseParameter['testColumn'] = testColumn
    parseParameter['columnLength'] = columnLength
    parseParameter['testRowAndValueList'] = testRowAndValueList
    parseParameter['testRowIndexList'] = testRowIndexList
    parseParameter['testValueIndexList'] = testValueIndexList
    parseParameter['STATIC_URL'] = STATIC_URL

    return render_to_response('demo_application/search/table_result.html', parseParameter)
コード例 #4
0
def tableResult(userParameter):
    """ This function: 1) Get user's online submission ; 2) Get and filter data from database 3) display as table """

    testType = userParameter['testType']
    testItem = userParameter['testItem']
    startTime = userParameter['startTime']
    endTime = userParameter['endTime']

    allSIObject = filterDataFromDatabase(testType, startTime, endTime)
    assert allSIObject != None, 'Failed To filter data, Please check user submission: testType=[%s], testItem=[%s], startTime=[%s], endTime=[%s]' % (
        testType, testItem, startTime, endTime)

    if len(allSIObject) == 0:
        parseParameter = {}
        parseParameter['testType'] = testType
        parseParameter['testItem'] = testItem
        parseParameter['no_data'] = 'no_data'
        parseParameter['STATIC_URL'] = STATIC_URL
        return render_to_response('demo_application/search/table_result.html',
                                  parseParameter)

    testResult = {}
    allItems = reverseGetAllFieldsMap(getAllFieldsMap(SI, getAll=False))
    for i in allSIObject:
        testItemName = allItems[testItem]
        #testResult[(i.testSoftware, i.testConfiguration)] = getattr(i, testItemName) # show horizontally
        testResult[(i.testConfiguration,
                    i.testSoftware)] = getattr(i,
                                               testItemName)  # show vertically
    testRow = list(set([i[0] for i in testResult]))
    testColumn = list(set([i[1] for i in testResult]))
    testValue = []
    for everyRow in testRow:
        #testValue.append([testResult.get((everyRow, everyColumn), '-') for everyColumn in testColumn])
        tempList = []
        for everyColumn in testColumn:
            value = testResult.get((everyRow, everyColumn), '-')
            if value == FLOATDEFAULT:
                value = '-'
            tempList.append(value)
        testValue.append(tempList)

    columnLength = len(testColumn)
    if CODEDEBUG == True:
        Color_Print(
            'green', 'Row is [%s] and Column is [%s] and Value is [%s]' %
            (testRow, testColumn, testValue))
        Color_Print('green', 'Value is [%s]' % testValue)

    assert len(testRow) == len(
        testValue), 'testRow is [%s] and testValue is [%s]' % (testRow,
                                                               testValue)
    #if len(testRow) != len(testValue):
    #    return render_to_response('demo_application/search/search_error.html', {})

    testRowAndValueList = []
    for index in range(len(testRow)):
        testRowAndValueList += [testRow[index]] + testValue[index]
    testRowIndexList = [
        index for index in range(len(testRowAndValueList))
        if testRowAndValueList[index] in testRow
    ]
    testValueIndexList = []
    for i in testRowIndexList:
        testValueIndexList.append(int(i) + len(testValue[0]))

    parseParameter = {}
    parseParameter['testResult'] = testResult
    parseParameter['testType'] = testType
    parseParameter['testItem'] = testItem
    parseParameter['testColumn'] = testColumn
    parseParameter['columnLength'] = columnLength
    parseParameter['testRowAndValueList'] = testRowAndValueList
    parseParameter['testRowIndexList'] = testRowIndexList
    parseParameter['testValueIndexList'] = testValueIndexList
    parseParameter['STATIC_URL'] = STATIC_URL

    return render_to_response('demo_application/search/table_result.html',
                              parseParameter)