commit 4cc90563332b75f2a7a215a09a3a9c4345a14a98
Author: vastja <vastja@gmail.com>
Date:   Sun May 10 17:14:54 2020 +0200

    + opravení generovaní dostupných datasetů, tak aby se při odeslání
    formuláře stránky zachovali se zvolenými údaji
    + 0-9 hodin fix

diff --git a/website/src/Controller/HeatmapController.php b/website/src/Controller/HeatmapController.php
index d9ce877..867202b 100644
--- a/website/src/Controller/HeatmapController.php
+++ b/website/src/Controller/HeatmapController.php
@@ -21,7 +21,6 @@ class HeatmapController extends AbstractController {
 
         // Todo validation
         // $form->isValid()
-        $dataSet = $form->getData();
         if ($form->isSubmitted()) {
             $dataSet = $form->getData();
         }
diff --git a/website/src/OpenDataManager.php b/website/src/OpenDataManager.php
index c32fb4d..80a142e 100644
--- a/website/src/OpenDataManager.php
+++ b/website/src/OpenDataManager.php
@@ -3,6 +3,7 @@
 namespace App\OpenData;
 
 use MongoDB\Driver\Query;
+use MongoDB\Driver\Command;
 use MongoDB\Driver\Manager;
 
 class OpenDataManager implements IOpenDataManager {
@@ -15,7 +16,8 @@ class OpenDataManager implements IOpenDataManager {
     }
 
     public function getCollectionDataByName($name, $date, $hour) {
-        $openData = $this->manager->executeQuery('open-data-db.'.$name.$date, new Query(['date' => $date.$hour], []));
+        $valh = $hour < 10 ? '0'.$hour : $hour;
+        $openData = $this->manager->executeQuery('open-data-db.'.$name.$date, new Query(['date' => $date.$valh], []));
 
         $openData->setTypeMap([
             'array' => 'array',
@@ -43,15 +45,10 @@ class OpenDataManager implements IOpenDataManager {
         $available = $this->getAvailableCollections();
         $index = 0;
         foreach ($available as $key => $value) {
-            $openData = $this->manager->executeQuery('open-data-db.'.$value['name'].$date, new Query([], []));
+            $command = new Command(['listCollections' => 1, 'filter' => ['name' => $value['name'].$date]]);
+            $result = $this->manager->executeCommand('open-data-db', $command)->toArray();
 
-            $openData->setTypeMap([
-                'array' => 'array',
-                'document' => 'array',
-                'root' => 'array',
-            ]);
-
-            if (false == empty($openData->toArray())) {
+            if (false == empty($result) && false == array_key_exists($value['name'], $availableInDate)) {
                 $availableInDate[$value['name']] = $index++;
             }
         }
@@ -68,6 +65,8 @@ class OpenDataManager implements IOpenDataManager {
             'root' => 'array',
         ]);
 
-        return $max->toArray()[0]['number'];
+        $result = $max->toArray();
+
+        return empty($result) ? 1 : $result[0]['number'];
     }
 }
diff --git a/website/src/Utils/Utils.php b/website/src/Utils/Utils.php
index c8a947d..78bdd8a 100644
--- a/website/src/Utils/Utils.php
+++ b/website/src/Utils/Utils.php
@@ -8,7 +8,9 @@ class Utils {
 
         $index = 0;
         foreach ($datasets as $key => $value) {
-            $names[$value['name']] = $index++;
+            if (false == array_key_exists($value['name'], $names)) {
+                $names[$value['name']] = $index++;
+            }
         }
 
         return $names;
diff --git a/website/templates/heatmap.html.twig b/website/templates/heatmap.html.twig
index bba30de..7cd573a 100644
--- a/website/templates/heatmap.html.twig
+++ b/website/templates/heatmap.html.twig
@@ -41,7 +41,7 @@
             </li>
 
             <li class="nav-item">
-              {{ form_label(form.date, 'Vyberte čas') }}
+              {{ form_label(form.time, 'Vyberte čas') }}
               {{
                 form_widget(form.time, {
                   'id' : 'time',
@@ -53,7 +53,7 @@
             </li>
 
             <li class="nav-item">
-              {{ form_label(form.date, 'Vybrané datové sady') }}
+              {{ form_label(form.type, 'Vybrané datové sady') }}
               {{
                 form_widget(form.type, {
                   'id' : 'type',
