code: def user_agents(self):
          return (self.get_query()
                  .select(
                      PageView.headers['User-Agent'],
                      fn.Count(PageView.id))
                  .group_by(PageView.headers['User-Agent'])
                  .order_by(fn.Count(PageView.id).desc())
                  .tuples())