示例#1
0
 def query_by_entity_uid(idd, kind=''):
     if kind == '':
         return g_Post2Tag.select().join(g_Tag).where(
             (g_Post2Tag.post == idd) & (g_Tag.kind != 'z')).order_by(
                 g_Post2Tag.order)
     else:
         return g_Post2Tag.select().join(g_Tag).where(
             (g_Tag.kind == kind) & (g_Post2Tag.post == idd)).order_by(
                 g_Post2Tag.order)
示例#2
0
 def get_app_relations(app_id, num=20, kind='1'):
     '''
     The the related infors.
     '''
     info_tag = MInfor2Catalog.get_first_category(app_id)
     if info_tag:
         return g_Post2Tag.select().join(
             g_Post).where((g_Post2Tag.tag == info_tag.tag.uid)
                           & (g_Post.kind == kind)).order_by(
                               peewee.fn.Random()).limit(num)
     else:
         return g_Post2Tag.select().join(g_Post).where(
             g_Post.kind == kind).order_by(peewee.fn.Random()).limit(num)
示例#3
0
 def query_by_post(postid):
     '''
     Query records by post.
     :param postid:
     :return:
     '''
     return g_Post2Tag.select().where(g_Post2Tag.post == postid).order_by(
         g_Post2Tag.order)
示例#4
0
 def update_count(cat_id):
     '''
     Update the count of certain category.
     :param cat_id:
     :return:
     '''
     entry2 = g_Tag.update(count=g_Post2Tag.select().where(
         g_Post2Tag.tag == cat_id).count()).where(g_Tag.uid == cat_id)
     entry2.execute()
示例#5
0
    def __get_by_info(post_id, catalog_id):
        recs = g_Post2Tag.select().where((g_Post2Tag.post == post_id)
                                         & (g_Post2Tag.tag == catalog_id))
        if recs.count() == 1:
            return recs.get()
        elif recs.count() > 1:
            # return the first one, and delete others.
            idx = 0
            out_rec = None
            for rec in recs:
                if idx == 0:
                    out_rec = rec
                else:
                    entry = g_Post2Tag.delete().where(
                        g_Post2Tag.uid == rec.uid)
                    entry.execute()
                idx += idx
            return out_rec.get()

        else:
            return None
示例#6
0
文件: label_model.py 项目: yws/TorCMS
    def get_by_info(post_id, catalog_id):
        tmp_recs = g_Post2Tag.select().join(g_Tag).where(
            (g_Post2Tag.post == post_id) & (g_Post2Tag.tag == catalog_id)
            & (g_Tag.kind == 'z'))

        if tmp_recs.count() > 1:
            ''' 如果多于1个,则全部删除
            '''
            idx = 0
            out_rec = None
            for tmp_rec in tmp_recs:
                if idx == 0:
                    out_rec = tmp_rec
                else:
                    entry = g_Post2Tag.delete().where(
                        g_Post2Tag.uid == tmp_rec.uid)
                    entry.execute()
                idx += 1
            return out_rec

        elif tmp_recs.count() == 1:
            return tmp_recs.get()
        else:
            return None
示例#7
0
文件: label_model.py 项目: yws/TorCMS
 def get_by_uid(idd, kind='z'):
     return g_Post2Tag.select().join(g_Tag).where((g_Post2Tag.post == idd)
                                                  & (g_Tag.kind == 'z'))
示例#8
0
文件: label_model.py 项目: yws/TorCMS
 def query_count(uid):
     return g_Post2Tag.select().where(g_Post2Tag.tag == uid).count()
示例#9
0
 def query_count():
     recs = g_Post2Tag.select(g_Post2Tag.tag,
                              peewee.fn.COUNT(
                                  g_Post2Tag.tag).alias('num')).group_by(
                                      g_Post2Tag.tag)
     return recs
示例#10
0
 def query_by_catid(catid):
     return g_Post2Tag.select().where(g_Post2Tag.tag == catid)
示例#11
0
 def count_of_certain_category(cat_id):
     return g_Post2Tag.select().where(g_Post2Tag.tag == cat_id).count()