update not insert duplicate logs
This commit is contained in:
parent
21cc5f2050
commit
82a5b0d0ad
|
@ -7,5 +7,5 @@ return [
|
|||
"maxPicture" => 9999,
|
||||
"version" => "1.0.7",
|
||||
"autoSyncLog" => false,
|
||||
"timeoutRequestServer" => 10
|
||||
"timeoutRequestServer" => 4
|
||||
];
|
||||
|
|
|
@ -58,6 +58,7 @@ class ApiController extends Controller {
|
|||
|
||||
public function actionGetLogs() {
|
||||
if (Yii::$app->request->post()) {
|
||||
Yii::$app->response->format = "json";
|
||||
$post = Yii::$app->request->bodyParams;
|
||||
$time = date_format(date_create_from_format('Y-m-d H:i:s', $post['time']), 'U');
|
||||
$key = common::generateRandomString();
|
||||
|
@ -73,6 +74,11 @@ class ApiController extends Controller {
|
|||
@unlink("/var/www/html/BiFace_Server_Lite/web/data/uploads/face/" . $lastLogs->image);
|
||||
$lastLogs->delete();
|
||||
}
|
||||
$lastLogs = CaptureLogs::find()->andWhere(["staff_id" => $post['id']])->orderBy(["time" => SORT_DESC])->limit(1)->one();
|
||||
if (($time - $lastLogs->time) < 1) {
|
||||
file_put_contents("log_connect_server.txt", "\n[" . date("H:i:s d/m/Y") . "] duplicate face " . $post["id"], FILE_APPEND);
|
||||
return ["status" => "success"];
|
||||
}
|
||||
|
||||
$model = new CaptureLogs();
|
||||
$logs = $model->create([
|
||||
|
@ -126,7 +132,6 @@ class ApiController extends Controller {
|
|||
file_put_contents("log_connect_server.txt", "\n[" . date("H:i:s d/m/Y") . "] /api/box/face_recognition_auth_v2 timeout " . $ip, FILE_APPEND);
|
||||
}
|
||||
}
|
||||
Yii::$app->response->format = "json";
|
||||
return ["status" => "success"];
|
||||
}
|
||||
}
|
||||
|
@ -407,7 +412,7 @@ class ApiController extends Controller {
|
|||
// file_put_contents("log_connect_server.txt", "\n" . date("H:i:s d/m/Y") . " connected " . $host . ":" . $port, FILE_APPEND);
|
||||
} else {
|
||||
$is_conn = false; //action in connection failure
|
||||
// file_put_contents("log_connect_server.txt", "\n" . date("H:i:s d/m/Y") . " disconnected " . $host . ":" . $port, FILE_APPEND);
|
||||
file_put_contents("log_connect_server.txt", "\n[" . date("H:i:s d/m/Y") . "] disconnected " . $host . ":" . $port, FILE_APPEND);
|
||||
}
|
||||
return $is_conn;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user