Keep the queries and ajax calls of those queries in the same function in
the Stats model