示例#1
0
 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 CabReply.select().join(CabPost2Catalog).where(
             CabPost2Catalog.catalog == cat_id).order_by(
                 peewee.fn.Random()).limit(num)
     elif config.dbtype == 2:
         return CabReply.select().join(CabPost2Catalog).where(
             CabPost2Catalog.catalog == cat_id).order_by(
                 peewee.fn.Rand()).limit(num)
示例#2
0
 def get_by_wiki(self, citiao):
     tt = CabReply.select().where(CabReply.title == citiao).count()
     if tt == 0:
         return None
     else:
         self.update_view_count(citiao)
         return CabReply.get(CabReply.title == citiao)
示例#3
0
 def get_previous_record(self, in_uid):
     current_rec = self.get_by_id(in_uid)
     query = CabReply.select().where(
         CabReply.time_update > current_rec.time_update).order_by(
             CabReply.time_update)
     if query.count() == 0:
         return None
     else:
         return query.get()
示例#4
0
 def get_by_keyword(self, par2):
     return CabReply.select().where(CabReply.title.contains(par2)).order_by(
         CabReply.time_update.desc()).limit(20)
示例#5
0
 def query_by_spec(self, spec_id):
     tt = CabReply.select().where(CabReply.id_spec == spec_id).order_by(
         CabReply.time_update.desc())
     return tt
示例#6
0
 def query_cat_by_pager(self, cat_str, cureent):
     tt = CabReply.select().where(CabReply.id_cats.contains(
         str(cat_str))).order_by(CabReply.time_update.desc()).paginate(
             cureent, config.page_num)
     return tt
示例#7
0
 def query_recent_most(self, num=8, recent=30):
     time_that = int(time.time()) - recent * 24 * 3600
     return CabReply.select().where(
         CabReply.time_update > time_that).order_by(
             CabReply.view_count.desc()).limit(num)
示例#8
0
 def get_by_id(self, in_uid):
     recs = CabReply.select().where(CabReply.post_id == in_uid).order_by(
         CabReply.timestamp.desc())
     return recs
示例#9
0
 def query_cat_recent(self, cat_id, num=8):
     return CabReply.select().join(CabPost2Catalog).where(
         CabPost2Catalog.catalog == cat_id).order_by(
             CabReply.time_update.desc()).limit(num)
示例#10
0
 def query_dated(self, num=8):
     return CabReply.select().order_by(CabReply.time_update).limit(num)
示例#11
0
 def query_recent(self, num=8):
     return CabReply.select().order_by(
         CabReply.time_update.desc()).limit(num)
示例#12
0
 def query_keywords_empty(self):
     return CabReply.select().where(CabReply.keywords == '')
示例#13
0
 def query_all(self):
     return CabReply.select()
示例#14
0
 def get_num_by_cat(self, cat_str):
     return CabReply.select().where(
         CabReply.id_cats.contains(',{0},'.format(cat_str))).count()
示例#15
0
 def query_old(self):
     return CabReply.select().order_by('time_update').limit(10)
示例#16
0
 def query_random(self, num=6):
     if config.dbtype == 1 or config.dbtype == 3:
         return CabReply.select().order_by(peewee.fn.Random()).limit(num)
     elif config.dbtype == 2:
         return CabReply.select().order_by(peewee.fn.Rand()).limit(num)
示例#17
0
 def query_most(self, num=8):
     return CabReply.select().order_by(
         CabReply.view_count.desc()).limit(num)