def get_by_wiki(citiao): q_res = g_Wiki.select().where(g_Wiki.title == citiao) tt = q_res.count() if tt == 0 or tt > 1: return None else: MWiki.update_view_count(citiao) return q_res.get()
def query_all(**kwargs): if 'kind' in kwargs: kind = kwargs['kind'] else: kind = '1' if 'limit' in kwargs: limit = kwargs['limit'] else: limit = 999999 return g_Wiki.select().where(g_Wiki.kind == kind).limit(limit)
def query_recent_edited(timstamp, kind='1'): return g_Wiki.select().where((g_Wiki.kind == kind) & ( g_Wiki.time_update > timstamp)).order_by(g_Wiki.time_update.desc())
def query_recent(num=8, kind='1'): return g_Wiki.select().where(g_Wiki.kind == kind).order_by( g_Wiki.time_update).limit(num)
def query_random(num=6, kind='1'): return g_Wiki.select().where(g_Wiki.kind == kind).order_by( peewee.fn.Random()).limit(num)
def get_counts(): ''' The count in table. :return: ''' return g_Wiki.select().count()
def query_most(num=8, kind='1'): return g_Wiki.select().where(g_Wiki.kind == kind).order_by( g_Wiki.view_count.desc()).limit(num)
def query_dated(num=10, kind='1'): return g_Wiki.select().where(g_Wiki.kind == kind).order_by( g_Wiki.time_update.desc()).limit(num)