def byUser(self, uid=None, username=None, limit=Config.defaultResultLimit): db = EnqueryPersistance() result = {} if uid is not None: result = db.getLastByUid(uid, limit) elif username is not None: result = db.getLastByUsername(username, limit) else: raise OperationalException('A username or UID is needed') return self.getPosts(result)
def hotTags(self, limit=Config.defaultResultLimit): db = EnqueryPersistance() return db.getHotTags(limit)
def byId(self, id): db = EnqueryPersistance() return self.getPosts(db.getPostById(id))
def byTag(self, tag, limit=Config.defaultResultLimit): db = EnqueryPersistance() return self.getPosts(db.getLastByTag(tag, limit))
def getPosts(self, items): db = EnqueryPersistance() for post in items: post['tags'] = db.getPostTags(post['id']) return items
def trendTags(self, limit=Config.defaultResultLimit): db = EnqueryPersistance() return db.getTrendTags(limit, trendPast=Config.trendPast)