Skip to content
Snippets Groups Projects

Resolve "Data ingress for context information for tiki-wiki"

2 files
+ 24
8
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -7,6 +7,7 @@ use Exception;
use Ingress\Command\BaseCommand;
use Ingress\Services\Logger;
use Ingress\Services\smartdataapi\SmartDataContextApiClient;
use Ingress\Services\smartdataapi\SmartDataUnits;
use Ingress\Services\tikiwiki\TikiWIkiConfig;
use Ingress\Services\tikiwiki\TikiWikiDB;
@@ -118,8 +119,8 @@ class ImportCommand extends BaseCommand
];
private static function convertKM($value) {
// TODO implement conversion to SI
return ["value" => $value];
// Convert the kilometers values to meters
return ["valueI32" => $value * 1000, "unit" => SmartDataUnits::METER];
}
private static function convertOwnerCount($value) {
@@ -127,13 +128,13 @@ class ImportCommand extends BaseCommand
}
private static function convertDate($value) {
// TODO implement conversion to SI
return ["value" => $value];
// Saves the epoch value as a time
return ["valueI64" => $value, "unit" => SmartDataUnits::TIME];
}
private static function convertKMLiter($value) {
// TODO implement conversion to SI
return ["value" => $value];
// Convert KM/L to M/L
return ["valueD32" => $value, "unit" => SmartDataUnits::METER];
}
private static function convertValueMap($value, $map) {
@@ -158,8 +159,13 @@ class ImportCommand extends BaseCommand
private static function convertServiceFrequency($key, $value)
{
// TODO calculate frequency
return ["kind" => $key, 'internal' => ['value' => $value]];
$numericValue = preg_replace('/\D/', '', $value);
if (str_contains($value, "km")) {
return ["kind" => $key, 'internal' => ['unit' => SmartDataUnits::METER, 'valueI32' => $numericValue * 1000]];
} else {
return ["kind" => $key, 'internal' => ['unit' => SmartDataUnits::TIME, 'valueI32' => $numericValue * SmartDataUnits::MONTH_TO_TIME_MULTIPLIER]];
}
}
private static function persistMaintenanceReport($tikiwikiid, $api, $data)
Loading