def get_by_wiki(self, citiao): tt = g_User2Reply.select().where(g_User2Reply.title == citiao).count() if tt == 0: return None else: self.update_view_count(citiao) return g_User2Reply.get(g_User2Reply.title == citiao)
def get_previous_record(self, in_uid): current_rec = self.get_by_id(in_uid) query = g_User2Reply.select().where(g_User2Reply.time_update > current_rec.time_update).order_by( g_User2Reply.time_update) if query.count() == 0: return None else: return query.get()
def create_reply(user_id, reply_id): record = g_User2Reply.select().where( (g_User2Reply.reply_id == reply_id) & (g_User2Reply.user_id == user_id)) if record.count() > 0: pass else: g_User2Reply.create( uid=tools.get_uuid(), reply_id=reply_id, user_id=user_id, timestamp=time.time(), )
def insert_data(self, user_id, reply_id): record = g_User2Reply.select().where( (g_User2Reply.reply_id == reply_id) & (g_User2Reply.user_id == user_id)) print('reply_voter_count', user_id, record.count()) if record.count() > 0: # return g_Voter2Reply.select().where(g_Voter2Reply.reply_id == reply_id).count() # return (False) pass else: g_User2Reply.create( uid=tools.get_uuid(), reply_id=reply_id, user_id=user_id, timestamp=time.time(), )
def get_by_zan(reply_id): return g_User2Reply.select().where( g_User2Reply.reply_id == reply_id).count()
def query_most(self, num=8): return g_User2Reply.select().order_by(g_User2Reply.view_count.desc()).limit(num)
def query_cat_recent(self, cat_id, num=8): return g_User2Reply.select().join(g_Post2Tag).where(g_Post2Tag.tag == cat_id).order_by( g_User2Reply.time_update.desc()).limit(num)
def query_dated(self, num=8): return g_User2Reply.select().order_by(g_User2Reply.time_update).limit(num)
def query_keywords_empty(self): return g_User2Reply.select().where(g_User2Reply.keywords == '')
def get_num_by_cat(self, cat_str): return g_User2Reply.select().where(g_User2Reply.id_cats.contains(',{0},'.format(cat_str))).count()
def get_voter_count(self, reply_id): return g_User2Reply.select().where(g_User2Reply.reply_id == reply_id).count()