This commit is contained in:
parent
26ec6de1e3
commit
a67d1eb05b
@ -19,7 +19,7 @@ CREATE TABLE IF NOT EXISTS "results" (
|
||||
"id" INTEGER,
|
||||
"event" INTEGER,
|
||||
"run" INTEGER,
|
||||
"rang" TEXT,
|
||||
"rang" INTEGER,
|
||||
"stnr" INTEGER,
|
||||
"teilnehmer" TEXT,
|
||||
"hund" TEXT,
|
||||
|
@ -184,6 +184,7 @@ function analyzeResultCSV($csv,$run,$event)
|
||||
$stnr = $row['stnr'];
|
||||
$teilnehmer = $row['teilnehmer'];
|
||||
$hund = $row['hund'];
|
||||
$rang = $row['rang'];
|
||||
$verein = $row['verein'];
|
||||
$f = $row['f'];
|
||||
$vw = $row['vw'];
|
||||
@ -198,7 +199,7 @@ function analyzeResultCSV($csv,$run,$event)
|
||||
{
|
||||
$res = $GLOBALS['db']->query("SELECT * FROM results WHERE stnr = '$stnr' AND run = '$run' AND event = '$event'");
|
||||
if($res->fetchArray() == false)
|
||||
$GLOBALS['db']->exec("INSERT INTO results (stnr, run, event, teilnehmer, hund, verein, f, vw, zf, zeit, gf, msek, bew) VALUES ('$stnr', '$run', '$event', '$teilnehmer', '$hund', '$verein', '$f', '$vw', '$zf', '$zeit', '$gf', '$msek', '$bew')");
|
||||
$GLOBALS['db']->exec("INSERT INTO results (stnr, rang, run, event, teilnehmer, hund, verein, f, vw, zf, zeit, gf, msek, bew) VALUES ('$stnr', '$rang', '$run', '$event', '$teilnehmer', '$hund', '$verein', '$f', '$vw', '$zf', '$zeit', '$gf', '$msek', '$bew')");
|
||||
}
|
||||
catch(Exception $ex) {
|
||||
//die( $ex->getMessage() );
|
||||
|
BIN
crawler/data.db
BIN
crawler/data.db
Binary file not shown.
@ -16,27 +16,44 @@ class Smart extends Page {
|
||||
|
||||
function search()
|
||||
{
|
||||
$db = new SQLite3(ROOT.DS.'../crawler/data.db');
|
||||
$db = new SQLite3(ROOT.DS.'../crawler/data.db', SQLITE3_OPEN_READONLY);
|
||||
$q = $_REQUEST['q'];
|
||||
$query = "SELECT * FROM results WHERE teilnehmer LIKE '$q'";
|
||||
if(!$q || strlen($q) < 3 || strpos($q, ' ') === false)
|
||||
return partial('error.html', ['errorTitle' => 'Error', 'errorMessage' => 'Error: Bitte Nachname und Vorname eingeben.']);
|
||||
$query = "SELECT DISTINCT(hund) FROM results WHERE teilnehmer LIKE '$q'";
|
||||
$res = $db->query($query);
|
||||
$results = [];
|
||||
$dogs = [];
|
||||
|
||||
while($row = $res->fetchArray())
|
||||
{
|
||||
$row['date'] = $db->querySingle("SELECT date FROM events WHERE id = ".$row['event']);
|
||||
$row['event'] = $db->querySingle("SELECT name FROM events WHERE id = ".$row['event']);
|
||||
$row['unixtimestamp'] = strtotime($row['date']);
|
||||
$row['run'] = $db->querySingle("SELECT name FROM runs WHERE id = ".$row['run']);
|
||||
$row['ago'] = printRelativeTime(time(),$row['unixtimestamp']);
|
||||
$results[] = $row;
|
||||
$dogs[] = $row['hund'];
|
||||
}
|
||||
|
||||
//sort results by date
|
||||
usort($results, function($a, $b) {
|
||||
return $b['unixtimestamp'] <=> $a['unixtimestamp'];
|
||||
});
|
||||
if(count($dogs) == 0)
|
||||
return partial('error.html', ['errorTitle' => 'Error', 'errorMessage' => 'Error: Keine Ergebnisse gefunden. Bitte Nachname und Vorname prüfen.']);
|
||||
|
||||
$this->set('results', $results);
|
||||
foreach($dogs as $dog)
|
||||
{
|
||||
$res = $db->query("SELECT * FROM results WHERE teilnehmer LIKE '$q' AND hund LIKE '$dog'");
|
||||
while($row = $res->fetchArray())
|
||||
{
|
||||
$row['date'] = $db->querySingle("SELECT date FROM events WHERE id = ".$row['event']);
|
||||
$row['event'] = $db->querySingle("SELECT name FROM events WHERE id = ".$row['event']);
|
||||
$row['unixtimestamp'] = strtotime($row['date']);
|
||||
$row['run'] = $db->querySingle("SELECT name FROM runs WHERE id = ".$row['run']);
|
||||
$row['ago'] = printRelativeTime(time(),$row['unixtimestamp']);
|
||||
$results[$dog][] = $row;
|
||||
}
|
||||
|
||||
//sort results by date
|
||||
usort($results[$dog], function($a, $b) {
|
||||
return $a['unixtimestamp'] <=> $b['unixtimestamp'];
|
||||
});
|
||||
}
|
||||
|
||||
$this->set('results_dogs', $results);
|
||||
$this->set('dogs', $dogs);
|
||||
$this->set('query', $query);
|
||||
$this->set('template', 'search.html.php');
|
||||
|
||||
|
@ -1,44 +1,159 @@
|
||||
<pre><?=$query;?></pre>
|
||||
|
||||
<table class="table">
|
||||
<tr>
|
||||
|
||||
<th>event</th>
|
||||
<th>Wann wars</th>
|
||||
<th>run</th>
|
||||
<th>rang</th>
|
||||
<th>stnr</th>
|
||||
<th>teilnehmer</th>
|
||||
<th>hund</th>
|
||||
<th>verein</th>
|
||||
<th>f</th>
|
||||
<th>vw</th>
|
||||
<th>zf</th>
|
||||
<th>zeit</th>
|
||||
<th>gf</th>
|
||||
<th>msek</th>
|
||||
<th>bew</th>
|
||||
<th>punkte</th>
|
||||
</tr>
|
||||
<?php foreach($results as $res): ?>
|
||||
<tr>
|
||||
<td><?= $res['event'] ?></td>
|
||||
<td><?= $res['ago'] ?></td>
|
||||
<td><?= $res['run'] ?></td>
|
||||
<td><?= $res['rang'] ?></td>
|
||||
<td><?= $res['stnr'] ?></td>
|
||||
<td><?= $res['teilnehmer'] ?></td>
|
||||
<td><?= $res['hund'] ?></td>
|
||||
<td><?= $res['verein'] ?></td>
|
||||
<td><?= $res['f'] ?></td>
|
||||
<td><?= $res['vw'] ?></td>
|
||||
<td><?= $res['zf'] ?></td>
|
||||
<td><?= $res['zeit'] ?></td>
|
||||
<td><?= $res['gf'] ?></td>
|
||||
<td><?= $res['msek'] ?></td>
|
||||
<td><?= $res['bew'] ?></td>
|
||||
<td><?= $res['punkte'] ?></td>
|
||||
|
||||
</tr>
|
||||
<h2>Hunde:</h2>
|
||||
<ul>
|
||||
<?php foreach ($dogs as $dog) : ?>
|
||||
<li><a href="#<?= $dog ?>"><?= $dog ?></a></li>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
</ul>
|
||||
|
||||
|
||||
<?php foreach ($dogs as $dog) :
|
||||
|
||||
$results = $results_dogs[$dog];
|
||||
?>
|
||||
|
||||
<h1 id="<?= $dog; ?>"><?= $dog; ?></h1>
|
||||
|
||||
<button onClick="getElementById('table_<?= $dog ?>').style.display='table'">Tabelle anzeigen</button>
|
||||
<table id="table_<?= $dog ?>" class="table" style="display:none">
|
||||
<tr>
|
||||
<th>event</th>
|
||||
<th>Wann wars</th>
|
||||
<th>run</th>
|
||||
<th>rang</th>
|
||||
<th>stnr</th>
|
||||
<th>teilnehmer</th>
|
||||
<th>hund</th>
|
||||
<th>verein</th>
|
||||
<th>f</th>
|
||||
<th>vw</th>
|
||||
<th>zf</th>
|
||||
<th>zeit</th>
|
||||
<th>gf</th>
|
||||
<th>msek</th>
|
||||
<th>bew</th>
|
||||
<th>punkte</th>
|
||||
</tr>
|
||||
<?php foreach ($results as $res) :
|
||||
// graph data preparation
|
||||
|
||||
//if ($res['bew'] != 'DIS' && $res['punkte'] != 'DIS')
|
||||
{
|
||||
$sdata['dates'][] = date("d.m.Y", strtotime($res['date']));
|
||||
$sdata['speed'][] = $res['msek'] ?: 0;
|
||||
$sdata['errors'][] = $res['f'] ?: 0;
|
||||
$sdata['refusals'][] = $res['vw'] ?: 0;
|
||||
$sdata['time'][] = $res['zeit'] ?: 0;
|
||||
$sdata['points'][] = $res['punkte'];
|
||||
$sdata['ranking'][] = $res['rang'];
|
||||
}
|
||||
|
||||
?>
|
||||
<tr>
|
||||
<td><?= $res['event'] ?></td>
|
||||
<td><?= $res['ago'] ?></td>
|
||||
<td><?= $res['run'] ?></td>
|
||||
<td><?= $res['rang'] ?></td>
|
||||
<td><?= $res['stnr'] ?></td>
|
||||
<td><?= $res['teilnehmer'] ?></td>
|
||||
<td><?= $res['hund'] ?></td>
|
||||
<td><?= $res['verein'] ?></td>
|
||||
<td><?= $res['f'] ?></td>
|
||||
<td><?= $res['vw'] ?></td>
|
||||
<td><?= $res['zf'] ?></td>
|
||||
<td><?= $res['zeit'] ?></td>
|
||||
<td><?= $res['gf'] ?></td>
|
||||
<td><?= $res['msek'] ?></td>
|
||||
<td><?= $res['bew'] ?></td>
|
||||
<td><?= $res['punkte'] ?></td>
|
||||
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
|
||||
<?php if (count($results) > 0) : ?>
|
||||
<div class="col">
|
||||
<div id="graph<?= $dog ?>" data-bs-theme="light" class="card bg-light text-black" style="min-height: 400px;"></div>
|
||||
|
||||
<script type="text/javascript">
|
||||
// Initialize the echarts instance based on the prepared dom
|
||||
var myChart = echarts.init(document.getElementById('graph<?= $dog ?>'));
|
||||
|
||||
// Specify the configuration items and data for the chart
|
||||
var option = {
|
||||
title: {
|
||||
text: 'Stacked Line'
|
||||
},
|
||||
tooltip: {
|
||||
trigger: 'axis'
|
||||
},
|
||||
legend: {
|
||||
data: ['Geschwindigkeit', 'Fehler', 'Verweigerungen', 'Zeit', 'Geschwindigkeit', 'Punkte', 'Platz']
|
||||
},
|
||||
grid: {
|
||||
left: '3%',
|
||||
right: '4%',
|
||||
bottom: '3%',
|
||||
containLabel: true
|
||||
},
|
||||
toolbox: {
|
||||
feature: {
|
||||
saveAsImage: {}
|
||||
}
|
||||
},
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
boundaryGap: false,
|
||||
data: <?= json_encode($sdata['dates']); ?>
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value'
|
||||
},
|
||||
series: [{
|
||||
name: 'Geschwindigkeit',
|
||||
type: 'line',
|
||||
stack: 'Total',
|
||||
data: <?= json_encode($sdata['speed']); ?>
|
||||
},
|
||||
{
|
||||
name: 'Fehler',
|
||||
type: 'line',
|
||||
stack: 'Total',
|
||||
data: <?= json_encode($sdata['errors']); ?>
|
||||
},
|
||||
{
|
||||
name: 'Verweigerungen',
|
||||
type: 'line',
|
||||
stack: 'Total',
|
||||
data: <?= json_encode($sdata['refusals']); ?>
|
||||
},
|
||||
{
|
||||
name: 'Zeit',
|
||||
type: 'line',
|
||||
stack: 'Total',
|
||||
data: <?= json_encode($sdata['time']); ?>
|
||||
},
|
||||
{
|
||||
name: 'Punkte',
|
||||
type: 'line',
|
||||
stack: 'Total',
|
||||
data: <?= json_encode($sdata['points']); ?>
|
||||
},
|
||||
{
|
||||
name: 'Platz',
|
||||
type: 'line',
|
||||
stack: 'Total',
|
||||
data: <?= json_encode($sdata['ranking']); ?>
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
// Display the chart using the configuration items and data just specified.
|
||||
myChart.setOption(option);
|
||||
</script>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
<hr>
|
||||
|
||||
<?php endforeach; ?>
|
Reference in New Issue
Block a user