Fix statistics page to use mongoDB aggregation framework