Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 70a3df53

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

+ Re #8086
+ php refactoring and comments

Zobrazit rozdíly:

website/src/Repository/OpenDataManager.php
5 5
use MongoDB\Driver\Query;
6 6
use MongoDB\Driver\Manager;
7 7

  
8
/**
9
 * Implementation of IOpenDataManager
10
 * autowired @see website/config/services.yaml and https://symfony.com/doc/current/service_container/autowiring.html.
11
 *
12
 * @see IOpenDataManager for methods comments
13
 */
8 14
class OpenDataManager implements IOpenDataManager {
15
    /**
16
     * @var IOpenDataManager autowired connection to database
17
     */
9 18
    private $manager;
10 19

  
20
    /**
21
     * @param IOpenDataManager autowired connection to database
22
     */
11 23
    public function __construct($connectionString) {
12 24
        $this->manager = new Manager(
13 25
            $connectionString
14
            // $_ENV['DATABASE_CONNECTION_STRING']
15 26
        );
16 27
    }
17 28

  
......
20 31
            return [];
21 32
        }
22 33

  
34
        // Number has to be two digit
23 35
        $valh = $hour < 10 ? '0'.$hour : $hour;
24 36
        $openData = $this->manager->executeQuery('open-data-db.'.$name.$date, new Query(['date' => $date.'-'.$valh], []));
25 37

  
38
        // Converts result to php array
26 39
        $openData->setTypeMap([
27 40
            'array' => 'array',
28 41
            'document' => 'array',
......
35 48
    public function getAvailableCollections() {
36 49
        $openData = $this->manager->executeQuery('open-data-db.DATASETS', new Query([], ['projection' => ['key-name' => 1, 'display-name' => 1, '_id' => 0]]));
37 50

  
51
        // Converts result to php array
38 52
        $openData->setTypeMap([
39 53
            'array' => 'array',
40 54
            'document' => 'array',
......
104 118

  
105 119
        $max = $this->manager->executeQuery('open-data-db.'.$name.$date, new Query([], ['sort' => ['number' => -1], 'limit' => 1]));
106 120

  
121
        // Converts result to php array
107 122
        $max->setTypeMap([
108 123
            'array' => 'array',
109 124
            'document' => 'array',
......
122 137

  
123 138
        $positions = $this->manager->executeQuery('open-data-db.'.$name.'DEVICES', new Query([], []));
124 139

  
140
        // Converts result to php array
125 141
        $positions->setTypeMap([
126 142
            'array' => 'array',
127 143
            'document' => 'array',

Také k dispozici: Unified diff