-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathlastgamets.php
44 lines (37 loc) · 1.57 KB
/
lastgamets.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
/* Definitions and main includes */
error_reporting(E_ALL);
$path = dirname((__FILE__)) . DIRECTORY_SEPARATOR;
require_once($path . "conf".DIRECTORY_SEPARATOR."conf.php");
require_once($path . "lib" .DIRECTORY_SEPARATOR."model_dynmodel.php");
require_once($path . "lib" .DIRECTORY_SEPARATOR."{$GLOBALS["DBDRIVER"]}.class.php");
require_once($path . "lib" .DIRECTORY_SEPARATOR."data_functions.php");
require_once($path . "lib" .DIRECTORY_SEPARATOR."chat_helper_functions.php");
require_once($path . "lib" .DIRECTORY_SEPARATOR."memory_helper_vectordb.php");
require_once($path . "lib" .DIRECTORY_SEPARATOR."memory_helper_embeddings.php");
$db = new sql();
$response = '';
try {
// Attempt to fetch the newest entry from eventlog based on the highest 'gamets' and 'ts'
//$query = "SELECT ts, gamets FROM eventlog ORDER BY gamets DESC LIMIT 1";
$query = "SELECT ts, gamets FROM eventlog ORDER BY gamets DESC, ts DESC LIMIT 1";
$result = $db->fetchAll($query);
// Check if the result has at least one row
if (count($result) > 0) {
// Grab the 'ts' and 'gamets' from the newest entry in eventlog
$ts = $result[0]['ts'];
$gamets = $result[0]['gamets'];
$response = $ts . '|' . $gamets;
} else {
// If the result is empty, send a unique message indicating this
$response = 'DB_EMPTY';
http_response_code(200);
}
} catch (Exception $e) {
// Send an appropriate error
$response = 'Error: ' . $e->getMessage();
http_response_code(500); // Internal Server Error
}
// Output the response
echo $response;
?>