dog overview
Build and push / Pulling repo on server (push) Successful in 3s Details

This commit is contained in:
Chris 2023-10-31 21:43:08 +00:00
parent af05f1d520
commit 7b79995796
5 changed files with 82 additions and 3 deletions

View File

@ -243,6 +243,11 @@ class Model {
return true;
}
function getTable()
{
return $this->dbTable;
}
function exists($id)
{
return $GLOBALS['redis']->exists($this->dbTable.':'.$id);

View File

@ -15,6 +15,39 @@ class Dog extends Model
'active' => ['type' => 'bool', 'default' => 1]
);
function getResults($dogid=false)
{
if(!$dogid)
$dogid = $this->id;
$res = new Result();
$keys = $GLOBALS['redis']->keys($res->getTable() . ':*');
$results = [];
foreach ($keys as $key) {
$id = end(explode(':', $key));
$res = new Result();
$res->load($id);
if ($res->data['dog'] == $dogid) {
$results[] = $res->data;
}
}
return $results;
}
function getRuns()
{
$run = new Run();
$keys = $GLOBALS['redis']->keys($run->dbTable . ':*');
$runs = [];
foreach ($keys as $key) {
$id = end(explode(':', $key));
$run = new Run();
$run->load($id);
if ($run->data['dog'] == $this->id)
$runs[] = $run->data;
}
return $runs;
}
function isMyDog($dog = false)
{
if ($dog == false)

View File

@ -209,11 +209,13 @@ class Dogs extends Page {
{
$dogid = $this->params[0];
$d = new Dog();
$res = new Result();
if(!$d->isMyDog($dogid))
return 'Not your dog :(';
$d->load($dogid);
$this->set('results', $d->getResults());
$this->set('dogdata', $d->data);
$this->set('dogid', $dogid);
$this->set('template', 'dog.html');

View File

@ -25,8 +25,47 @@
</div>
</div>
</div>
<div class="col-8" id="sitemain">
<div class="col-9" id="sitemain">
<!-- table of all runs of this dog-->
<div class="card p-2">
<h4>Ergebnisse</h4>
<p class="card-text">
<button hx-get="/dogs/addresult/<?= $dogid; ?>" hx-push-url="/dogs/addresult/<?= $dogid; ?>" hx-target="#main" class="btn btn-primary"><i class="fas fa-plus-circle"></i> Ergebnis Eintragen</button>
</p>
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th>Platz</th>
<th>Disqualifiziert</th>
<th>Verweigerungen</th>
<th>Fehler</th>
<th>Zeitfehler</th>
<th>Zeit</th>
<th>Gesamtfehler</th>
<th>m/Sek</th>
<th>Bewertung</th>
<th>Teilnehmer</th>
</tr>
</thead>
<tbody>
<?php foreach($results as $result) : ?>
<tr>
<td><?= escape($result['ranking']); ?></td>
<td><?= $result['disqualified']?'Ja':'Nein'; ?></td>
<td><?= escape($result['refusals']); ?></td>
<td><?= escape($result['errors']); ?></td>
<td><?= escape($result['timefaults']); ?></td>
<td><?= escape($result['runtime']); ?></td>
<td><?= escape($result['penalties']); ?></td>
<td><?= escape($result['speed']); ?></td>
<td><?= escape($result['rating']); ?></td>
<td><a href="/dogs/overview/<?= $result['dog'] ?>"><?= escape( (new Dog())->getField('name',$result['dog']) ); ?></a></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div>

View File

@ -77,7 +77,7 @@
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>