38
38
use DateTimeImmutable ;
39
39
use DateTimeInterface ;
40
40
use DBmysql ;
41
- use GlpiPlugin \Carbon \CarbonIntensitySource ;
41
+ use GlpiPlugin \Carbon \Source ;
42
42
use GlpiPlugin \Carbon \Zone ;
43
43
use Glpi \DBAL \QueryParam ;
44
44
use GlpiPlugin \Carbon \DataSource \CarbonIntensity \ClientInterface ;
@@ -92,9 +92,9 @@ public function rawSearchOptions()
92
92
93
93
$ tab [] = [
94
94
'id ' => SearchOptions::CARBON_INTENSITY_SOURCE ,
95
- 'table ' => CarbonIntensitySource ::getTable (),
95
+ 'table ' => Source ::getTable (),
96
96
'field ' => 'name ' ,
97
- 'name ' => CarbonIntensitySource ::getTypeName (1 ),
97
+ 'name ' => Source ::getTypeName (1 ),
98
98
'massiveaction ' => false , // implicit field is id
99
99
'datatype ' => 'dropdown ' ,
100
100
];
@@ -131,15 +131,15 @@ public function rawSearchOptions()
131
131
private function getKnownDatesQuery (string $ zone_name , string $ source_name )
132
132
{
133
133
$ intensity_table = CarbonIntensity::getTable ();
134
- $ source_table = CarbonIntensitySource ::getTable ();
134
+ $ source_table = Source ::getTable ();
135
135
$ zone_table = Zone::getTable ();
136
136
return [
137
137
'SELECT ' => [$ intensity_table => ['id ' , 'date ' ]],
138
138
'FROM ' => $ intensity_table ,
139
139
'INNER JOIN ' => [
140
140
$ source_table => [
141
141
'FKEY ' => [
142
- $ intensity_table => CarbonIntensitySource ::getForeignKeyField (),
142
+ $ intensity_table => Source ::getForeignKeyField (),
143
143
$ source_table => 'id ' ,
144
144
]
145
145
],
@@ -151,7 +151,7 @@ private function getKnownDatesQuery(string $zone_name, string $source_name)
151
151
]
152
152
],
153
153
'WHERE ' => [
154
- CarbonIntensitySource ::getTableField ('name ' ) => $ source_name ,
154
+ Source ::getTableField ('name ' ) => $ source_name ,
155
155
Zone::getTableField ('name ' ) => $ zone_name
156
156
],
157
157
];
@@ -218,7 +218,7 @@ public function downloadOneZone(ClientInterface $data_source, string $zone_name,
218
218
$ total_count = 0 ;
219
219
220
220
// Check if there are gaps to fill
221
- $ source = new CarbonIntensitySource ();
221
+ $ source = new Source ();
222
222
$ source ->getFromDBByCrit (['name ' => $ data_source ->getSourceName ()]);
223
223
$ zone = new Zone ();
224
224
$ zone ->getFromDBByCrit (['name ' => $ zone_name ]);
@@ -334,7 +334,7 @@ public function save(string $zone_name, string $source_name, array $data): int
334
334
global $ DB ;
335
335
336
336
$ count = 0 ;
337
- $ source = new CarbonIntensitySource ();
337
+ $ source = new Source ();
338
338
$ source ->getFromDBByCrit ([
339
339
'name ' => $ source_name ,
340
340
]);
@@ -357,7 +357,7 @@ public function save(string $zone_name, string $source_name, array $data): int
357
357
CarbonIntensity::getTable (),
358
358
[
359
359
'date ' => new QueryParam (),
360
- CarbonIntensitySource ::getForeignKeyField () => new QueryParam (),
360
+ Source ::getForeignKeyField () => new QueryParam (),
361
361
Zone::getForeignKeyField () => new QueryParam (),
362
362
'intensity ' => new QueryParam (),
363
363
'data_quality ' => new QueryParam (),
@@ -399,7 +399,7 @@ public function save(string $zone_name, string $source_name, array $data): int
399
399
public function findGaps (int $ source_id , int $ zone_id , DateTimeInterface $ start , ?DateTimeInterface $ stop = null ): array
400
400
{
401
401
$ criteria = [
402
- CarbonIntensitySource ::getForeignKeyField () => $ source_id ,
402
+ Source ::getForeignKeyField () => $ source_id ,
403
403
Zone::getForeignKeyField () => $ zone_id ,
404
404
];
405
405
$ interval = new DateInterval ('PT1H ' );
0 commit comments