Projekt

Obecné

Profil

« Předchozí | Další » 

Revize dfe43218

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

+ validace

Zobrazit rozdíly:

website/src/OpenDataManager.php
45 45
        $available = $this->getAvailableCollections();
46 46
        $index = 0;
47 47
        foreach ($available as $key => $value) {
48
            $command = new Command(['listCollections' => 1, 'filter' => ['name' => $value['name'].$date]]);
49
            $result = $this->manager->executeCommand('open-data-db', $command)->toArray();
50

  
51
            if (false == empty($result) && false == array_key_exists($value['name'], $availableInDate)) {
48
            if ($this->isCollectionAvailable($value['name'], $date) && false == array_key_exists($value['name'], $availableInDate)) {
52 49
                $availableInDate[$value['name']] = $index++;
53 50
            }
54 51
        }
......
56 53
        return $availableInDate;
57 54
    }
58 55

  
56
    public function getXthAvailableCollectionByDay($index, $date) {
57
        $availableInDate = [];
58
        $available = $this->getAvailableCollections();
59
        $currentIndex = 0;
60

  
61
        foreach ($available as $key => $value) {
62
            if ($this->isCollectionAvailable($value['name'], $date) && false == array_key_exists($value['name'], $availableInDate)) {
63
                if ($currentIndex == $index) {
64
                    return $value['name'];
65
                }
66
                else {
67
                    $currentIndex++;
68
                }
69
            }
70
        }
71

  
72
        return "";
73
    }
74

  
75
    public function isCollectionAvailable($name, $date) {
76

  
77
        $command = new Command(['listCollections' => 1, 'filter' => ['name' => $name.$date]]);
78
        $result = $this->manager->executeCommand('open-data-db', $command)->toArray();
79

  
80
        return !empty($result);
81
    }
82

  
59 83
    public function getMaxCollectionNumberAtDay($name, $date) {
60 84
        $max = $this->manager->executeQuery('open-data-db.'.$name.$date, new Query([], ['sort' => ['number' => -1], 'limit' => 1]));
61 85

  

Také k dispozici: Unified diff