def query_cat_random(self, cat_id, num=6): if cat_id == '': return self.query_random(num) if config.dbtype == 1 or config.dbtype == 3: return CabPost.select().join(CabPost2Catalog).where(CabPost2Catalog.catalog == cat_id).order_by( peewee.fn.Random()).limit(num) elif config.dbtype == 2: return CabPost.select().join(CabPost2Catalog).where(CabPost2Catalog.catalog == cat_id).order_by( peewee.fn.Rand()).limit(num)
def query_cat_random(self, cat_id, num=6): if cat_id == '': return self.query_random(num) if config.dbtype == 1 or config.dbtype == 3: return CabPost.select().join(CabPost2Catalog).where( CabPost2Catalog.catalog == cat_id).order_by( peewee.fn.Random()).limit(num) elif config.dbtype == 2: return CabPost.select().join(CabPost2Catalog).where( CabPost2Catalog.catalog == cat_id).order_by( peewee.fn.Rand()).limit(num)
def get_previous_record(self, in_uid): current_rec = self.get_by_id(in_uid) query = CabPost.select().where(CabPost.time_update > current_rec.time_update).order_by(CabPost.time_update) if query.count() == 0: return None else: return query.get()
def get_by_wiki(self, citiao): tt = CabPost.select().where(CabPost.title == citiao).count() if tt == 0: return None else: self.update_view_count(citiao) return CabPost.get(CabPost.title == citiao)
def get_by_wiki(self, citiao): tt = CabPost.select().where(CabPost.title == citiao).count() if tt == 0: return None else: self.update_view_count(citiao) return CabPost.get(CabPost.title == citiao)
def get_previous_record(self, in_uid): current_rec = self.get_by_id(in_uid) query = CabPost.select().where( CabPost.time_update > current_rec.time_update).order_by( CabPost.time_update) if query.count() == 0: return None else: return query.get()
def query_cat_by_pager(self, cat_str, cureent): tt = CabPost.select().where(CabPost.id_cats.contains(str(cat_str))).order_by( CabPost.time_update.desc()).paginate(cureent, config.page_num) return tt
def query_most(self, num=8): return CabPost.select().order_by(CabPost.view_count.desc()).limit(num)
def query_cat_recent(self, cat_id, num=8): return CabPost.select().join(CabPost2Catalog).where( CabPost2Catalog.catalog == cat_id).order_by( CabPost.time_update.desc()).limit(num)
def query_dated(self, num=8): return CabPost.select().order_by(CabPost.time_update.asc()).limit(num)
def get_num_by_cat(self, cat_str): return CabPost.select().where(CabPost.id_cats.contains(',{0},'.format(cat_str))).count()
def get_num_by_cat(self, cat_str): return CabPost.select().where( CabPost.id_cats.contains(',{0},'.format(cat_str))).count()
def query_cat_by_pager(self, cat_str, cureent): tt = CabPost.select().where(CabPost.id_cats.contains( str(cat_str))).order_by(CabPost.time_update.desc()).paginate( cureent, config.page_num) return tt
def query_most(self, num=8): return CabPost.select().order_by(CabPost.view_count.desc()).limit(num)
def delete_last_post(self): # Todo: delete query = CabPost.select().order_by(CabPost.time_update.desc()).limit(1).get() self.delete(query.uid)
def query_keywords_empty(self): return CabPost.select().where(CabPost.keywords == '')
def query_dated(self, num=8): return CabPost.select().order_by(CabPost.time_update.asc()).limit(num)
def query_keywords_empty(self): return CabPost.select().where(CabPost.keywords == '')
def query_cat_recent(self, cat_id, num=8): return CabPost.select().join(CabPost2Catalog).where(CabPost2Catalog.catalog == cat_id).order_by( CabPost.time_update.desc()).limit(num)
def query_most_pic(self, num): return CabPost.select().where(CabPost.logo != "").order_by(CabPost.view_count.desc()).limit(num)
def query_most_pic(self, num): return CabPost.select().where(CabPost.logo != "").order_by( CabPost.view_count.desc()).limit(num)