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