bookmark collections
This commit is contained in:
@@ -352,19 +352,35 @@ class BookmarkCollections(Model):
|
||||
return not (self.has_posts() or self.has_threads())
|
||||
|
||||
def get_threads(self):
|
||||
q = 'SELECT thread_id FROM bookmarked_threads WHERE collection_id = ?'
|
||||
q = 'SELECT id FROM bookmarked_threads WHERE collection_id = ?'
|
||||
res = db.query(q, self.id)
|
||||
return [Threads.find({'id': bt['thread_id']}) for bt in res]
|
||||
return [BookmarkedThreads.find({'id': bt['id']}) for bt in res]
|
||||
|
||||
def get_posts(self):
|
||||
q = 'SELECT post_id FROM bookmarked_posts WHERE collection_id = ?'
|
||||
q = 'SELECT id FROM bookmarked_posts WHERE collection_id = ?'
|
||||
res = db.query(q, self.id)
|
||||
return [Posts.find({'id': bt['post_id']}) for bt in res]
|
||||
return [BookmarkedPosts.find({'id': bt['id']}) for bt in res]
|
||||
|
||||
def get_threads_count(self):
|
||||
q = 'SELECT COUNT(*) as tc FROM bookmarked_threads WHERE collection_id = ?'
|
||||
res = db.fetch_one(q, self.id)
|
||||
return int(res['tc'])
|
||||
|
||||
def get_posts_count(self):
|
||||
q = 'SELECT COUNT(*) as pc FROM bookmarked_posts WHERE collection_id = ?'
|
||||
res = db.fetch_one(q, self.id)
|
||||
return int(res['pc'])
|
||||
|
||||
|
||||
class BookmarkedPosts(Model):
|
||||
table = 'bookmarked_posts'
|
||||
|
||||
def get_post(self):
|
||||
return Posts.find({'id': self.post_id})
|
||||
|
||||
|
||||
class BookmarkedThreads(Model):
|
||||
table = 'bookmarked_threads'
|
||||
|
||||
def get_thread(self):
|
||||
return Threads.find({'id': self.thread_id})
|
||||
|
||||
Reference in New Issue
Block a user