From 1d8d3c1d4687acfd61ebf8cd9bcc2c7fa6ce290b Mon Sep 17 00:00:00 2001 From: Ruben Date: Sat, 17 Sep 2016 22:32:42 +0100 Subject: [PATCH] Few fixes --- bin/generate_db.php | 3 ++- src/Api/ScoreControllerProvider.php | 17 +++++++++++------ src/Models/Hit.php | 4 ++-- src/Models/Level.php | 1 - src/Models/UserRepository.php | 2 +- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/bin/generate_db.php b/bin/generate_db.php index cc3d906..47044b6 100644 --- a/bin/generate_db.php +++ b/bin/generate_db.php @@ -5,7 +5,8 @@ chdir(__DIR__); require_once __DIR__ . "/../bootstrap.php"; - +error_reporting(E_ALL); +ini_set('display_errors',) // Show table creation statements // And (re)generate Proxies diff --git a/src/Api/ScoreControllerProvider.php b/src/Api/ScoreControllerProvider.php index d8fa527..ced86f1 100644 --- a/src/Api/ScoreControllerProvider.php +++ b/src/Api/ScoreControllerProvider.php @@ -72,7 +72,7 @@ class ScoreControllerProvider implements ControllerProviderInterface $level = $this->_eh->getEm()->getRepository(Models\Level::class)->find($data['lvl_id']); if(empty($level)) { - return new JsonResponse(['success' => false, 'message' => "Invalid level"], 400); + return new JsonResponse(['success' => false, 'message' => "Invalid level" , "lvl_id" => (int) $data['lvl_id']], 400); } $game = new Models\Game(); @@ -193,9 +193,13 @@ class ScoreControllerProvider implements ControllerProviderInterface if(empty($hit) || $hit->getGame()->getUser()->getId() != $user->getId()) { return new JsonResponse(['success' => false, 'message' => "Hit not found."], 400); } - $targetFilename = $hit->getFeatureFilename($part); + $targetDirname = $hit->getFeatureDirname($part); + + if($targetDirname == null) { + return new JsonResponse(['success' => false, 'message' => "Something went wrong. Invalid part?", "part" => (string) $part], 400); + } - $file->move($targetFilename); + $file->move($targetDirname, $hit->getId().'.jpg'); $hit->setHasImage(true); $em->persist($hit); } @@ -234,21 +238,22 @@ class ScoreControllerProvider implements ControllerProviderInterface 'pitch' => [], 'yaw' => [], 'inter_ocular_distance' => [], - 'mouth_open' => ["JawDropStretched"], + // 'mouth_open' => ["JawDropStretched"], + 'mouth_open' => ["UpperLipUp","lowerLipDown"], 'lip_press' => ["lowerLipUp"], 'brow_raise' => ["RightOuterBrowUp","LeftOuterBrowUp"], 'nose_wrinkler' => ["NasolabialDeepener"], 'lip_depressor' => ["MouthRightPullDown","MouthLeftPullDown"], 'brow_furrow' => ["NoseWrinkler"], 'attention' => [], - 'smile' => ["MouthRightPullUp","MouthLeftPullUp","UpperLipUp","lowerLipDown"], + // 'smile' => ["MouthRightPullUp","MouthLeftPullUp", "UpperLipUp","lowerLipDown"], 'smile' => ["UpperLipStretched"], 'inner_brow_raiser' => ["RightInnerBrowUp","LeftInnerBrowUp"], 'chin_raiser' => ["ChinForward"], 'smirk' => ["MouthLeftPullUp"], 'lip_suck' => ["UpperLipBackward","lowerLipBackward"], 'upper_lip_raiser' => ["UpperLipUp"], - 'lip_pucker' => ["LipsKiss"], + // 'lip_pucker' => ["LipsKiss"], 'lip_pucker' => ["UpperLipForward","lowerLipForward"], 'eye_closure' => ["RightUpperLidClosed","LeftUpperLidClosed"], 'engagement' => [], diff --git a/src/Models/Hit.php b/src/Models/Hit.php index 030cd76..6860a77 100644 --- a/src/Models/Hit.php +++ b/src/Models/Hit.php @@ -206,12 +206,12 @@ class Hit * @return string|false false if not exists * @throws \Exception */ - public function getFeatureFilename(string $feature) { + public function getFeatureDirname(string $feature) { if(!in_array($feature, static::$FEATURES)) { throw new \Exception("Invalid feature!"); } - return realpath(__DIR__ . "/../../files/hits/".$feature."/".$this->getId() . '.jpg' ); + return realpath(__DIR__ . "/../../files/hits/".$feature) ; } /** diff --git a/src/Models/Level.php b/src/Models/Level.php index 8cead74..9c66d70 100644 --- a/src/Models/Level.php +++ b/src/Models/Level.php @@ -19,7 +19,6 @@ class Level * * @ORM\Column(name="id",type="integer") * @ORM\Id - * @ORM\GeneratedValue */ private $id; diff --git a/src/Models/UserRepository.php b/src/Models/UserRepository.php index 721d742..b834658 100644 --- a/src/Models/UserRepository.php +++ b/src/Models/UserRepository.php @@ -67,7 +67,7 @@ class UserRepository extends EntityRepository implements UserProviderInterface $results = $query->getScalarResult(); $score = 0; foreach($results as $result) { - $score += $results['score']; + $score += $result['score']; } $user->setTotalScore($score);