Exemplo n.º 1
0
def who_rated(custId, itemId, rate):
    """ get those who rate 3 """
    pattern = rate_item_key.format(custId=custId, raterId='*', itemId=itemId)
    raters = []
    pat = re.compile(r'RATE-ME\|[\w\d-]*\|([\w\d-]*)\|[\w\d-]*')
    for each in r.keys(pattern):
        rater = re.findall(pat, each.decode('utf-8'))
        if len(rater) and r.get(each) and r.get(each).decode('utf-8')==rate:
            raters.append(rater[0])
    return json.dumps(dict(result=raters))
Exemplo n.º 2
0
def get_rate(custId, raterId, itemId):
    """ get rating """
    key = rate_item_key.format(custId=custId, raterId=raterId, itemId=itemId)
    return json.dumps(dict(result=r.get(key)))