Projekt

Obecné

Profil

« Předchozí | Další » 

Revize d8f6e6f2

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

Re #8094
+ method for retrieving all dates with at least one dataset

Zobrazit rozdíly:

website/src/Controller/HeatmapController.php
54 54
    public function availableDatasets(IOpenDataManager $manager, $date = '01012020') {
55 55
        return $this->json($manager->getAvailableCollectionsByDay($date));
56 56
    }
57

  
58
    /**
59
     * @Route("heatmap/dates", name="dates")
60
     */
61
    public function datesWithAvailableDatasets(IOpenDataManager $manager) {
62
        return $this->json($manager->getDatesWithAvailableCollection());
63
    }
57 64
}
website/src/IOpenDataManager.php
11 11

  
12 12
    public function isCollectionAvailable($name, $date);
13 13

  
14
    public function getDatesWithAvailableCollection();
15

  
14 16
    public function getMaxCollectionNumberAtDay($name, $date);
15 17
}
website/src/OpenDataManager.php
60 60
        return !empty($result);
61 61
    }
62 62

  
63
    public function getDatesWithAvailableCollection() {
64
        $command = new Command(['listCollections' => 1]);
65
        $result = $this->manager->executeCommand('open-data-db', $command)->toArray();
66

  
67
        $dates = [];
68
        foreach ($result as $value) {
69
            if (preg_match('/\\d{4}-\\d{2}-\\d{2}/', $value->name)) {
70
                array_push($dates, substr($value->name, -10));
71
            }
72
        }
73

  
74
        return array_values(array_unique($dates));
75
    }
76

  
63 77
    public function getMaxCollectionNumberAtDay($name, $date) {
64 78
        $max = $this->manager->executeQuery('open-data-db.'.$name.$date, new Query([], ['sort' => ['number' => -1], 'limit' => 1]));
65 79

  

Také k dispozici: Unified diff