Beispiel #1
0
 /**
  * Returns the latest results for each test in the requested group
  * 
  * @Route("/group/{id}")
  * @Method({"GET"})
  * @Security("is_granted('view', group)")
  * @ApiDoc(
  *     requirements={
  *         {"name"="id", "description"="The ID of the group for which to return results for", "dataType"="integer", "requirement"="\d+"}
  *     },
  *     filters={
  *         {"name"="pageSize", "description"="How many results to return per test per page","type"="Integer","default"=10,"maximum"=100},
  *         {"name"="page", "description"="The page number to return results from","type"="Integer","default"=1}
  *     },
  *     tags={
  *         "Super Admin" = "#ff1919",
  *         "Admin" = "#ffff33",
  *         "User" = "#75ff47"
  *     }
  * )
  */
 public function getRecentGroupResults(TestGroup $group, Request $request)
 {
     $results = [];
     $size = $request->query->get('pageSize', 10);
     foreach ($group->getTests()->toArray() as $test) {
         $results[] = $this->getEntityRepository("OverwatchResultBundle:TestResult")->getResults(["test" => $test], $size >= 100 ? 10 : $size, $request->query->get('page', 1));
     }
     return new JsonResponse($results);
 }
 /**
  * Returns a list of tests in the given group
  * 
  * @Route("/group/{id}")
  * @Method({"GET"})
  * @Security("is_granted('view', group)")
  * @ApiDoc(
  *     requirements={
  *         {"name"="id", "description"="The ID of the group to return tests from", "dataType"="integer", "requirement"="\d+"}
  *     },
  *     tags={
  *         "Super Admin" = "#ff1919",
  *         "Admin" = "#ffff33",
  *         "User" = "#75ff47"
  *     }
  * )
  */
 public function getTestsInGroup(TestGroup $group)
 {
     return new JsonResponse($group->getTests()->toArray());
 }
 /**
  * Deletes the given group
  * 
  * @Route("/{id}")
  * @Method({"DELETE"})
  * @Security("has_role('ROLE_SUPER_ADMIN')")
  * @ApiDoc(
  *     requirements={
  *         {"name"="id", "description"="The ID of the group to delete", "dataType"="integer", "requirement"="\d+"}
  *     },
  *     tags={
  *         "Super Admin" = "#ff1919"
  *     }
  * )
  */
 public function deleteGroup(TestGroup $group)
 {
     if ($group->getUsers()->count() + $group->getTests()->count() !== 0) {
         return new JsonResponse("This group still has users and/or tests in it. You must remove them before continuing.", JsonResponse::HTTP_UNPROCESSABLE_ENTITY);
     }
     $this->_em->remove($group);
     $this->_em->flush();
     return new JsonResponse(NULL, JsonResponse::HTTP_NO_CONTENT);
 }