<commit_before><?php
require_once 'global.php';

$templateData = [];
foreach($config as $key => $value) {
	$sensor = [
		"value" => $latest[$key],
		"unit" => $value["unit"],
		"measurement" => $value["measurement"],
		"location" => $value["location"],
		"sensorID" => $key
	];
	if (isset($value["small"]) && $value["small"]) {
		$sensor["small"] = true;
	}
	$templateData[] = $sensor;
}

$smarty->assign('ready', true);
$smarty->assign('sensors', $templateData);
$smarty->assign('measurementTime', 2);
$smarty->display('index.tpl');
<commit_msg>Use live data (TODO: fix measurementTime?)<commit_after><?php
require_once 'global.php';

function queryData($obj_store) {
	$data = $obj_store->fetchAll("SELECT * FROM Measurement ORDER BY recorded DESC LIMIT 1");
	$dataArray = [];
	foreach($data as $obj_ent) {
		array_push($dataArray, $obj_ent->getData());
	}
	return array_reverse($dataArray);
}

$data = queryData($obj_store);
$templateData = [];
foreach($config as $key => $value) {
	$liveval = 0;
	if (isset($data[$key])) {
		$liveval = $data[$key];
	}
	$sensor = [
		"value" => $liveval,
		"unit" => $value["unit"],
		"measurement" => $value["measurement"],
		"location" => $value["location"],
		"sensorID" => $key
	];
	if (isset($value["small"]) && $value["small"]) {
		$sensor["small"] = true;
	}
	$templateData[] = $sensor;
}

$smarty->assign('ready', true);
$smarty->assign('sensors', $templateData);
$smarty->assign('measurementTime', 2);
$smarty->display('index.tpl');

{'fraction_non_alphanumeric': 0.2354533152909337, 'fraction_numerical': 0.0027063599458728013, 'mean_word_length': 5.911214953271028, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2693543', 'n_tokens_mistral': 549, 'n_tokens_neox': 531, 'n_words': 99}