Esempio n. 1
0
    def delete(uid):
        '''
        Delete by uid
        :param uid:
        :return:
        '''

        q_u1 = TabPostHist.delete().where(TabPostHist.post_id == uid)
        q_u1.execute()
        q_u2 = TabRel.delete().where(TabRel.post_f_id == uid
                                     or TabRel.post_t_id == uid)
        q_u2.execute()
        q_u3 = TabCollect.delete().where(TabCollect.post_id == uid)
        q_u3.execute()
        q_u4 = TabPost2Tag.delete().where(TabPost2Tag.post_id == uid)
        q_u4.execute()
        q_u5 = TabUsage.delete().where(TabUsage.post_id == uid)
        q_u5.execute()

        reply_arr = []
        for reply in TabUser2Reply.select().where(
                TabUser2Reply.reply_id == uid):
            reply_arr.append(reply.reply_id.uid)

        q_u6 = TabUser2Reply.delete().where(TabUser2Reply.reply_id == uid)
        q_u6.execute()

        for replyid in reply_arr:
            TabReply.delete().where(TabReply.uid == replyid).execute()

        q_u7 = TabEvaluation.delete().where(TabEvaluation.post_id == uid)
        q_u7.execute()
        q_u8 = TabRating.delete().where(TabRating.post_id == uid)
        q_u8.execute()
        return MHelper.delete(TabPost, uid)
Esempio n. 2
0
 def add_or_update(user_id, app_id, value):
     '''
     Editing evaluation.
     '''
     rec = MEvaluation.get_by_signature(user_id, app_id)
     if rec:
         entry = TabEvaluation.update(
             value=value, ).where(TabEvaluation.uid == rec.uid)
         entry.execute()
     else:
         TabEvaluation.create(
             uid=tools.get_uuid(),
             user_id=user_id,
             post_id=app_id,
             value=value,
         )
Esempio n. 3
0
 def app_evaluation_count(app_id, value=1):
     '''
     Get the Evalution sum.
     '''
     return TabEvaluation.select().where(
         (TabEvaluation.post_id == app_id)
         & (TabEvaluation.value == value)).count()
Esempio n. 4
0
 def get_by_signature(user_id, app_id):
     '''
     get by user ID, and app ID.
     '''
     try:
         return TabEvaluation.get((TabEvaluation.user_id == user_id)
                                  & (TabEvaluation.post_id == app_id))
     except:
         return None
Esempio n. 5
0
 def get_by_signature(user_id, app_id):
     '''
     :param user_id:
     :param app_id:
     :return:
     '''
     try:
         return TabEvaluation.get((TabEvaluation.user_id == user_id)
                                  & (TabEvaluation.post_id == app_id))
     except:
         return None