'Get all visitors by IP and then list the pages they visited in order.'

def trail(self):

    inner = self.get_query().select(PageView.ip, PageView.url).order_by(PageView.timestamp)
    return PageView.select(PageView.ip, fn.array_agg(PageView.url).coerce(False).alias('urls')).from_(inner.alias('t1')).group_by(PageView.ip)
