update confidence + version

This commit is contained in:
2021-04-23 16:58:19 +07:00
parent 1b1162f3c2
commit b006af4e1f
7 changed files with 63 additions and 12 deletions

View File

@@ -78,7 +78,7 @@ class ApiController extends Controller {
"Staff" => $post["id"],
"Time" => $time,
"Image" => $fileName,
"Confidence" => strval($post["confidence"])
"Confidence" => json_encode($post["confidence"])
]);
$server_ip = \app\models\SyncUrl::findOne(['key_config' => 'server_api']);
$ip = "https://dev-dc.beetai.com";
@@ -259,13 +259,21 @@ class ApiController extends Controller {
]);
$updating = \app\models\SyncUrl::findOne(['key_config' => 'updating']);
}
$currentCache = json_decode(file_get_contents("http://localhost:2305/current-cache"), true);
if ($updating->data === "true") {
$txt = "\n" . date("H:i:s d/m/Y") . " " . "updating";
file_put_contents(date('Ymd') . "_logs.txt", $txt, FILE_APPEND);
return ["status" => false];
if ($currentCache['n_128'] == $currentCache['n_512']) {
$updating->data = "false";
$updating->save();
$txt = "\n" . date("H:i:s d/m/Y") . " " . "success";
file_put_contents(date('Ymd') . "_logs.txt", $txt, FILE_APPEND);
return ["status" => false];
} else {
$txt = "\n" . date("H:i:s d/m/Y") . " " . "updating";
file_put_contents(date('Ymd') . "_logs.txt", $txt, FILE_APPEND);
return ["status" => false];
}
}
$currentCache = json_decode(file_get_contents("http://localhost:2305/current-cache"), true);
if ($currentCache['n_128'] == $currentCache['n_512']) {
$txt = "\n" . date("H:i:s d/m/Y") . " " . "success";
file_put_contents(date('Ymd') . "_logs.txt", $txt, FILE_APPEND);
@@ -407,6 +415,17 @@ class ApiController extends Controller {
'data' => $post['token']
]);
}
$version = \app\models\SyncUrl::findOne(['key_config' => 'version']);
if ($version) {
$token->data = $post['version'];
$token->save();
} else {
$model = new \app\models\SyncUrl();
$model->create([
'key_config' => "version",
'data' => $post['version']
]);
}
Yii::$app->response->format = "json";
return ["status" => true];
}