Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 4cc90563

Přidáno uživatelem Jakub Vašta před asi 4 roky(ů)

+ 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

Zobrazit rozdíly:

website/src/OpenDataManager.php
3 3
namespace App\OpenData;
4 4

  
5 5
use MongoDB\Driver\Query;
6
use MongoDB\Driver\Command;
6 7
use MongoDB\Driver\Manager;
7 8

  
8 9
class OpenDataManager implements IOpenDataManager {
......
15 16
    }
16 17

  
17 18
    public function getCollectionDataByName($name, $date, $hour) {
18
        $openData = $this->manager->executeQuery('open-data-db.'.$name.$date, new Query(['date' => $date.$hour], []));
19
        $valh = $hour < 10 ? '0'.$hour : $hour;
20
        $openData = $this->manager->executeQuery('open-data-db.'.$name.$date, new Query(['date' => $date.$valh], []));
19 21

  
20 22
        $openData->setTypeMap([
21 23
            'array' => 'array',
......
43 45
        $available = $this->getAvailableCollections();
44 46
        $index = 0;
45 47
        foreach ($available as $key => $value) {
46
            $openData = $this->manager->executeQuery('open-data-db.'.$value['name'].$date, new Query([], []));
48
            $command = new Command(['listCollections' => 1, 'filter' => ['name' => $value['name'].$date]]);
49
            $result = $this->manager->executeCommand('open-data-db', $command)->toArray();
47 50

  
48
            $openData->setTypeMap([
49
                'array' => 'array',
50
                'document' => 'array',
51
                'root' => 'array',
52
            ]);
53

  
54
            if (false == empty($openData->toArray())) {
51
            if (false == empty($result) && false == array_key_exists($value['name'], $availableInDate)) {
55 52
                $availableInDate[$value['name']] = $index++;
56 53
            }
57 54
        }
......
68 65
            'root' => 'array',
69 66
        ]);
70 67

  
71
        return $max->toArray()[0]['number'];
68
        $result = $max->toArray();
69

  
70
        return empty($result) ? 1 : $result[0]['number'];
72 71
    }
73 72
}

Také k dispozici: Unified diff