Exemplo n.º 1
0
 def query_random(self, num=6):
     if config.dbtype == 1 or config.dbtype == 3:
         return CabVoter2Reply.select().order_by(
             peewee.fn.Random()).limit(num)
     elif config.dbtype == 2:
         return CabVoter2Reply.select().order_by(
             peewee.fn.Rand()).limit(num)
Exemplo n.º 2
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 CabVoter2Reply.select().join(CabPost2Catalog).where(CabPost2Catalog.catalog == cat_id).order_by(
             peewee.fn.Random()).limit(num)
     elif config.dbtype == 2:
         return CabVoter2Reply.select().join(CabPost2Catalog).where(CabPost2Catalog.catalog == cat_id).order_by(
             peewee.fn.Rand()).limit(num)
Exemplo n.º 3
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 CabVoter2Reply.select().join(CabPost2Catalog).where(
             CabPost2Catalog.catalog == cat_id).order_by(
                 peewee.fn.Random()).limit(num)
     elif config.dbtype == 2:
         return CabVoter2Reply.select().join(CabPost2Catalog).where(
             CabPost2Catalog.catalog == cat_id).order_by(
                 peewee.fn.Rand()).limit(num)
Exemplo n.º 4
0
 def get_by_wiki(self, citiao):
     tt = CabVoter2Reply.select().where(CabVoter2Reply.title == citiao).count()
     if tt == 0:
         return None
     else:
         self.update_view_count(citiao)
         return CabVoter2Reply.get(CabVoter2Reply.title == citiao)
Exemplo n.º 5
0
 def get_previous_record(self, in_uid):
     current_rec = self.get_by_id(in_uid)
     query = CabVoter2Reply.select().where(CabVoter2Reply.time_update > current_rec.time_update).order_by(
         CabVoter2Reply.time_update)
     if query.count() == 0:
         return None
     else:
         return query.get()
Exemplo n.º 6
0
 def get_by_wiki(self, citiao):
     tt = CabVoter2Reply.select().where(
         CabVoter2Reply.title == citiao).count()
     if tt == 0:
         return None
     else:
         self.update_view_count(citiao)
         return CabVoter2Reply.get(CabVoter2Reply.title == citiao)
Exemplo n.º 7
0
    def insert_data(self, user_id, reply_id):

        record = CabVoter2Reply.select().where(
            (CabVoter2Reply.reply_id == reply_id) & ( CabVoter2Reply.voter_id == user_id ))

        if record.count() > 0:
            pass
            return (False)
        else:
            entry = CabVoter2Reply.create(
                uid=tools.get_uuid(),
                reply_id=reply_id,
                voter_id=user_id,
                timestamp=time.time(),
            )
            cur_count = CabVoter2Reply.select().where(CabVoter2Reply.reply_id == reply_id).count()

            return cur_count
Exemplo n.º 8
0
 def get_previous_record(self, in_uid):
     current_rec = self.get_by_id(in_uid)
     query = CabVoter2Reply.select().where(
         CabVoter2Reply.time_update > current_rec.time_update).order_by(
             CabVoter2Reply.time_update)
     if query.count() == 0:
         return None
     else:
         return query.get()
Exemplo n.º 9
0
    def insert_data(self, user_id, reply_id):

        record = CabVoter2Reply.select().where(
            (CabVoter2Reply.reply_id == reply_id) & (CabVoter2Reply.voter_id == user_id))

        if record.count() > 0:
            return (False)

        try:
            CabVoter2Reply.create(
                uid=tools.get_uuid(),
                reply_id=reply_id,
                voter_id=user_id,
                timestamp=time.time(),
            )
            return CabVoter2Reply.select().where(CabVoter2Reply.reply_id == reply_id).count()

        except:
            return False
Exemplo n.º 10
0
    def insert_data(self, user_id, reply_id):

        record = CabVoter2Reply.select().where(
            (CabVoter2Reply.reply_id == reply_id)
            & (CabVoter2Reply.voter_id == user_id))

        if record.count() > 0:
            return (False)

        try:
            CabVoter2Reply.create(
                uid=tools.get_uuid(),
                reply_id=reply_id,
                voter_id=user_id,
                timestamp=time.time(),
            )
            return CabVoter2Reply.select().where(
                CabVoter2Reply.reply_id == reply_id).count()

        except:
            return False
Exemplo n.º 11
0
 def query_most(self, num=8):
     return CabVoter2Reply.select().order_by(
         CabVoter2Reply.view_count.desc()).limit(num)
Exemplo n.º 12
0
 def query_dated(self, num=8):
     return CabVoter2Reply.select().order_by(
         CabVoter2Reply.time_update).limit(num)
Exemplo n.º 13
0
 def query_cat_recent(self, cat_id, num=8):
     return CabVoter2Reply.select().join(CabPost2Catalog).where(
         CabPost2Catalog.catalog == cat_id).order_by(
             CabVoter2Reply.time_update.desc()).limit(num)
Exemplo n.º 14
0
 def query_keywords_empty(self):
     return CabVoter2Reply.select().where(CabVoter2Reply.keywords == '')
Exemplo n.º 15
0
 def query_recent(self, num=8):
     return CabVoter2Reply.select().order_by(
         CabVoter2Reply.time_update.desc()).limit(num)
Exemplo n.º 16
0
 def query_cat_recent(self, cat_id, num=8):
     return CabVoter2Reply.select().join(CabPost2Catalog).where(
         CabPost2Catalog.catalog == cat_id).order_by(
             CabVoter2Reply.time_update.desc()).limit(num)
Exemplo n.º 17
0
 def query_all(self):
     return CabVoter2Reply.select()
Exemplo n.º 18
0
 def get_by_zan(self, reply_id):
     return CabVoter2Reply.select().where(CabVoter2Reply.reply_id == reply_id).count()
Exemplo n.º 19
0
 def get_by_id(self, in_uid):
     recs = CabVoter2Reply.select().where(
         CabVoter2Reply.reply_id == in_uid).order_by(
             CabVoter2Reply.timestamp.desc())
     return recs
Exemplo n.º 20
0
 def get_num_by_cat(self, cat_str):
     return CabVoter2Reply.select().where(
         CabVoter2Reply.id_cats.contains(',{0},'.format(cat_str))).count()
Exemplo n.º 21
0
 def query_old(self):
     return CabVoter2Reply.select().order_by('time_update').limit(10)
Exemplo n.º 22
0
 def query_by_spec(self, spec_id):
     tt = CabVoter2Reply.select().where(
         CabVoter2Reply.id_spec == spec_id).order_by(
             CabVoter2Reply.time_update.desc())
     return tt
Exemplo n.º 23
0
 def query_keywords_empty(self):
     return CabVoter2Reply.select().where(CabVoter2Reply.keywords == '')
Exemplo n.º 24
0
 def query_most(self, num=8):
     return CabVoter2Reply.select().order_by(
         CabVoter2Reply.view_count.desc()).limit(num)
Exemplo n.º 25
0
 def query_recent_most(self, num=8, recent=30):
     time_that = int(time.time()) - recent * 24 * 3600
     return CabVoter2Reply.select().where(
         CabVoter2Reply.time_update > time_that).order_by(
             CabVoter2Reply.view_count.desc()).limit(num)
Exemplo n.º 26
0
 def get_num_by_cat(self, cat_str):
     return CabVoter2Reply.select().where(
         CabVoter2Reply.id_cats.contains(',{0},'.format(cat_str))).count()
Exemplo n.º 27
0
 def query_cat_by_pager(self, cat_str, cureent):
     tt = CabVoter2Reply.select().where(
         CabVoter2Reply.id_cats.contains(str(cat_str))).order_by(
             CabVoter2Reply.time_update.desc()).paginate(
                 cureent, config.page_num)
     return tt
Exemplo n.º 28
0
 def query_dated(self, num=8):
     return CabVoter2Reply.select().order_by(
         CabVoter2Reply.time_update).limit(num)
Exemplo n.º 29
0
 def get_by_keyword(self, par2):
     return CabVoter2Reply.select().where(
         CabVoter2Reply.title.contains(par2)).order_by(
             CabVoter2Reply.time_update.desc()).limit(20)
Exemplo n.º 30
0
 def get_by_zan(self, reply_id):
     return CabVoter2Reply.select().where(
         CabVoter2Reply.reply_id == reply_id).count()