示例#1
0
def getFeatureNCategoryFromDB():
    sql = "select id,feature,category from m_feature"
    result = databaseOperation(sql)
    response = []
    if result:
        for row in result:
            feature = Feature(row[2], row[0], None, row[1], None, None)
            response.append(json.dumps(feature.__dict__))
    return response
示例#2
0
def getAllFeaturesFromDB():
    sql = "select * from m_feature"
    result = databaseOperation(sql)
    response = []
    if result:
        for row in result:
            feature = Feature(row[4], row[0], row[3], row[1], row[5], row[2])
            response.append(json.dumps(feature.__dict__))
    return response
def getAllCriteriaFromDB():
    sql = "select * from m_criteria"
    result = databaseOperation(sql)
    response = []
    if result:
        for row in result:
            # id 0, product 3, category 2, datasource 4, sqlapi 5, keyvalue 6, feature 1)
            criteria = Criteria(row[0], row[3], row[2], row[4], row[5], row[6], row[1])
            response.append(json.dumps(criteria.__dict__))
    return response
示例#4
0
def getByFeatureId(id):
    sql = "select * from m_feature where id = '%d'" % id
    result = databaseOperation(sql)
    if result:
        for row in result:
            feature = Feature(row[4], id, row[3], row[1], row[5], row[2])

        return feature
    else:
        return None
def getByCriteriaId():
    sql = "select * from m_criteria where id = '%d'" % id
    result = databaseOperation(sql)
    if result:
        for row in result:
            # id, product, category, datasource, sqlapi, keyvalue, feature
            criteria = Criteria(row[0], row[3], row[2], row[4], row[5], row[6], row[1])

        return criteria
    else:
        return None
示例#6
0
def getByConfigId(id):
    sql = "select * from m_configuration where id = '%d'" % id
    result = databaseOperation(sql)
    if result:
        for row in result:
            configuration = Configuration(row[0], row[1], row[2], row[3],
                                          row[4], row[5], row[6], row[7],
                                          row[8], row[9], row[10])

        return configuration
    else:
        return None
示例#7
0
def getAllConfigurationFromDB():
    sql = "select * from m_configuration"
    result = databaseOperation(sql)
    response = []
    if result:
        for row in result:

            configuration = Configuration(row[0], row[1], row[2], row[3],
                                          row[4], row[5], row[6], row[7],
                                          row[8], row[9], row[10])
            response.append(json.dumps(configuration.__dict__))
    return response
示例#8
0
def getByGender(gender):
    sql = "SELECT cs.criteria, (CONVERT(cs.score, DECIMAL(10,2)) * CONVERT(a.weightage , DECIMAL(10,2))) as mul " \
          "FROM mifostenant.m_criteriascore as cs, mifostenant.m_configuration a " \
          "where cs.cscriteriatableid = a.id and  Upper(a.feature)= 'GENDER' and cs.cscriteriatableid=2"
    result = databaseOperation(sql)
    score = 0
    if(result):
        for row in result:
            criteria = row[0]
            if(criteria.upper() == gender):
                score = float(row[1])
                break
    return score
示例#9
0
def getByAge(age):
    sql = "SELECT cs.criteria, (CONVERT(cs.score, DECIMAL(10,2)) * CONVERT(a.weightage , DECIMAL(10,2))) as mul " \
          "FROM mifostenant.m_criteriascore as cs, mifostenant.m_configuration a " \
          "where cs.cscriteriatableid = a.id and  a.feature = 'Age' and cs.cscriteriatableid=1"
    result = databaseOperation(sql)
    score = 0
    if(result):
        for row in result:
            criteria = row[0]
            minage, maxage = criteria.split('-')
            if(age >= int(minage) and age <= int(maxage)):
                score = float(row[1])
                break
    return score