示例#1
0
 def count_of_user(user_id):
     '''
     Get the cound of views.
     '''
     return TabCollect.select(
         TabCollect, TabPost.uid.alias('post_uid'),
         TabPost.title.alias('post_title'),
         TabPost.view_count.alias('post_view_count')).where(
             TabCollect.user_id == user_id).join(
                 TabPost, on=(TabCollect.post_id == TabPost.uid)).count()
示例#2
0
    def query_pager_by_userid(user_id, kind, num=10):

        recs = TabCollect.select(
            TabCollect, TabPost.uid.alias('post_uid'),
            TabPost.title.alias('post_title'), TabPost.kind.alias('post_kind'),
            TabPost.view_count.alias('post_view_count')).where(
                (TabCollect.user_id == user_id) & (TabPost.kind == kind)).join(
                    TabPost, on=(TabCollect.post_id == TabPost.uid)).order_by(
                        TabCollect.timestamp.desc()).limit(num)
        return recs
示例#3
0
    def query_pager_by_all(user_id, current_page_num=1):

        recs = TabCollect.select(
            TabCollect, TabPost.uid.alias('post_uid'),
            TabPost.title.alias('post_title'),
            TabPost.view_count.alias('post_view_count')).where(
                TabCollect.user_id == user_id).join(
                    TabPost, on=(TabCollect.post_id == TabPost.uid)).order_by(
                        TabCollect.timestamp.desc()).paginate(
                            current_page_num, CMS_CFG['list_num'])
        return recs
示例#4
0
 def query_recent(user_id, num=10):
     '''
     Collection of recent.
     '''
     return TabCollect.select(
         TabCollect, TabPost.uid.alias('post_uid'),
         TabPost.title.alias('post_title'),
         TabPost.view_count.alias('post_view_count')).where(
             TabCollect.user_id == user_id).join(
                 TabPost, on=(TabCollect.post_id == TabPost.uid)).order_by(
                     TabCollect.timestamp.desc()).limit(num)