From 7b799957961c5408e3c9c02057b33406b7eb9f94 Mon Sep 17 00:00:00 2001 From: Chris Date: Tue, 31 Oct 2023 21:43:08 +0000 Subject: [PATCH] dog overview --- web/inc/classes/Model.class.php | 5 ++++ web/models/Dog.model.php | 33 +++++++++++++++++++++++++ web/pages/dogs/controller.php | 2 ++ web/pages/dogs/dog.html | 43 +++++++++++++++++++++++++++++++-- web/pages/runs/run.html | 2 +- 5 files changed, 82 insertions(+), 3 deletions(-) diff --git a/web/inc/classes/Model.class.php b/web/inc/classes/Model.class.php index 21e7926..108239d 100644 --- a/web/inc/classes/Model.class.php +++ b/web/inc/classes/Model.class.php @@ -243,6 +243,11 @@ class Model { return true; } + function getTable() + { + return $this->dbTable; + } + function exists($id) { return $GLOBALS['redis']->exists($this->dbTable.':'.$id); diff --git a/web/models/Dog.model.php b/web/models/Dog.model.php index 3f4f23c..e58b8c6 100644 --- a/web/models/Dog.model.php +++ b/web/models/Dog.model.php @@ -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) diff --git a/web/pages/dogs/controller.php b/web/pages/dogs/controller.php index 3bb70b9..42e2671 100644 --- a/web/pages/dogs/controller.php +++ b/web/pages/dogs/controller.php @@ -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'); diff --git a/web/pages/dogs/dog.html b/web/pages/dogs/dog.html index 806c465..c6ecd5a 100644 --- a/web/pages/dogs/dog.html +++ b/web/pages/dogs/dog.html @@ -25,8 +25,47 @@ -
- +
+ +
+

Ergebnisse

+

+ +

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
PlatzDisqualifiziertVerweigerungenFehlerZeitfehlerZeitGesamtfehlerm/SekBewertungTeilnehmer
getField('name',$result['dog']) ); ?>
+
diff --git a/web/pages/runs/run.html b/web/pages/runs/run.html index 0b88405..b4508a3 100644 --- a/web/pages/runs/run.html +++ b/web/pages/runs/run.html @@ -77,7 +77,7 @@ - +