Beispiel #1
0
    def get_visits(self, uid=None, page_size=100, offset=0):
        params = {'offset': offset, 'limit': page_size}
        visits = Visit.select().paginate((offset % page_size) + 1, page_size)

        if uid:
            params.update({'uid': uid})
            visits = (Visit.select(Visit, User.nickname).where(
                Visit.uid == uid).join(User).group_by(Visit).paginate(
                    (offset % page_size) + 1, page_size))
        else:
            visits = (Visit.select(
                Visit, User.nickname).join(User).group_by(Visit).paginate(
                    (offset % page_size) + 1, page_size))

        raise gen.Return(visits)
Beispiel #2
0
 def get_visits_total(self, uid=None):
     if uid:
         results_count = Visit.select().where(Visit.uid == uid).count()
     else:
         results_count = Visit.select().count()
     raise gen.Return(results_count)