Fix images fixed order

This commit is contained in:
Ruben 2016-11-03 01:12:21 +01:00
parent c975392069
commit d9d79447ff

View file

@ -29,17 +29,19 @@ class InterfaceControllerProvider implements ControllerProviderInterface
$getEmoBlocks = function($emotion, $feature, $steps = 6) { $getEmoBlocks = function($emotion, $feature, $steps = 6) {
$hitRepo = $this->_eh->getEm()->getRepository(Models\Hit::class); $hitRepo = $this->_eh->getEm()->getRepository(Models\Hit::class);
$blocks = []; $blocks = [];
$a = 1;
foreach(range(0, 100, 100/($steps-1)) as $i) { foreach(range(0, 100, 100/($steps-1)) as $i) {
/* @var $hitRepo EmotionHero\Models\HitRepository */ /* @var $hitRepo EmotionHero\Models\HitRepository */
$hit = $hitRepo->getClosestHitWithImage($emotion, $i); $hit = $hitRepo->getClosestHitWithImage($emotion, $i);
$img = "data:image/x-icon;base64,".$hit->getFeatureImgAsString($feature); $img = "data:image/x-icon;base64,".$hit->getFeatureImgAsString($feature);
$score = $hit->getEmotions()->getEmotionScore($emotion); $score = $hit->getEmotions()->getEmotionScore($emotion);
$percentage = sprintf("%.0f %%",$score); $percentage = sprintf("%.0f %%",$score);
$blocks[$i] = [ $blocks[$a] = [
'hit_id' => $hit->getId(), 'hit_id' => $hit->getId(),
'img_data' => $img, 'img_data' => $img,
'percentage' => $percentage, 'percentage' => $percentage,
]; ];
$a++;
} }
return $blocks; return $blocks;
}; };