Beispiel #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))
Beispiel #2
0
def get_raters(custId, itemId):
    """ get ratters """

    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):
            raters.append(rater[0])
    return json.dumps(dict(redult=raters))