Add unit tests for Redis namespace safety, MotorAPI cache functionality, and configuration classes, alongside implementation of xlvask_automation_service
- Added tests to ensure Redis namespace safety for `db_object_t` and `users_o`. - Implemented `MotorApiCachedResultTest` to validate metadata caching behavior. - Introduced configuration classes for `xlvask_automatic_order_attachment_enabled` and `xlvask_automatic_order_creation_enabled`. - Developed `xlvask_automation_service` with supporting features for usage log evaluation, suggestion building, and order automation.
This commit is contained in:
@@ -155,7 +155,7 @@ class motorapi implements motorapi_i
|
||||
// Get the cached result from the log/local database/cache
|
||||
$motorapi_lookups = new motorapi_lookups_o();
|
||||
// Add the cached value to the meta
|
||||
$response->add_meta('cached', true);
|
||||
self::addCachedMetaIfPossible($response);
|
||||
$cleaned_result = self::cleanJSON($motorapi_lookups->getCachedResult($licensePlate)->result->value());
|
||||
$object = json_decode($cleaned_result);
|
||||
if ($object === null) {
|
||||
@@ -165,6 +165,13 @@ class motorapi implements motorapi_i
|
||||
return json_decode($cleaned_result);
|
||||
}
|
||||
|
||||
public static function addCachedMetaIfPossible(mixed $response): void
|
||||
{
|
||||
if (is_object($response) && method_exists($response, 'add_meta')) {
|
||||
$response->add_meta('cached', true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @throws Exception If the module is not enabled, the license plate is invalid, the daily limit is exceeded, or the secret key is invalid
|
||||
@@ -385,4 +392,4 @@ class motorapi implements motorapi_i
|
||||
$motorapi_lookups = new motorapi_lookups_o();
|
||||
$motorapi_lookups->add($licensePlate, json_encode($response), $endpoint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user