Subversion Repositories SmartDukaan

Rev

Rev 13642 | Rev 13778 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 13642 Rev 13771
Line 111... Line 111...
111
        result['currPage'] = page    
111
        result['currPage'] = page    
112
        return result
112
        return result
113
    else:
113
    else:
114
        return result
114
        return result
115
 
115
 
-
 
116
def getDeals(category_id, offset, limit):
116
def main():
117
    rank = 1
-
 
118
    deals = {}
-
 
119
    if category_id == "0":
-
 
120
        print "Getting all cat"
-
 
121
        data = list(get_mongo_connection().Catalog.Deals.find({'rank':{'$gt':0}}).sort([('totalPoints',pymongo.DESCENDING)]).skip(int(offset)).limit(int(limit)))
117
    pass
122
    else:
-
 
123
        data = list(get_mongo_connection().Catalog.Deals.find({'rank':{'$gt':0},'category_id':int(category_id)}).sort([('totalPoints',pymongo.DESCENDING)]).skip(int(offset)).limit(int(limit)))
-
 
124
    for d in data:
-
 
125
        item = list(get_mongo_connection().Catalog.MasterData.find({'_id':d['_id']}))
-
 
126
        if not deals.has_key(item[0]['identifier']):
-
 
127
            item[0]['dealRank'] = rank 
-
 
128
            deals[item[0]['identifier']] = item[0]
-
 
129
            rank +=1
-
 
130
    return deals.values()
118
    
131
    
-
 
132
 
-
 
133
def main():
-
 
134
    getDeals("0", "0", "10")
119
if __name__=='__main__':
135
if __name__=='__main__':
120
    main()
136
    main()
121
137