Fix the owner issue

Rebasing
pull/81/head
DahmaneYanis 1 year ago committed by d_yanis
parent 90b18008eb
commit d816b3b0aa

@ -21,12 +21,12 @@
#body { #body {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
border : solid 10px yellow; border : solid 10px violet;
margin:0px margin:0px
} }
#personal-space { #personal-space {
background-color: red; background-color: orange;
} }
#sideMenu { #sideMenu {

@ -23,8 +23,8 @@ class UserController {
* @return ViewHttpResponse the home page view * @return ViewHttpResponse the home page view
*/ */
public function home(SessionHandle $session): ViewHttpResponse { public function home(SessionHandle $session): ViewHttpResponse {
$lastTactic = $this->tactics->getLast(5); $limitNbTactics = 5;
var_dump($session->getAccount()); $lastTactic = $this->tactics->getLast($limitNbTactics, $session->getAccount()->getId());
return ViewHttpResponse::react("views/Home.tsx", [ return ViewHttpResponse::react("views/Home.tsx", [
"lastTactics" => $lastTactic "lastTactics" => $lastTactic
]); ]);

@ -45,10 +45,16 @@ class TacticInfoGateway {
* @param integer $nb * @param integer $nb
* @return array<array<string,mixed>> * @return array<array<string,mixed>>
*/ */
public function getLast(int $nb): ?array { public function getLast(int $nb, int $ownerId): ?array {
$res = $this->con->fetch( $res = $this->con->fetch(
"SELECT * FROM Tactic ORDER BY creation_date DESC LIMIT :nb ", "SELECT *
[":nb" => [$nb, PDO::PARAM_INT]] FROM Tactic
WHERE owner = :ownerId
ORDER BY creation_date
DESC LIMIT :nb",
[
":ownerId" => [$ownerId, PDO::PARAM_INT],":nb" => [$nb, PDO::PARAM_INT]
]
); );
if (count($res) == 0) { if (count($res) == 0) {
return []; return [];

@ -3,6 +3,7 @@
namespace IQBall\Core\Model; namespace IQBall\Core\Model;
use IQBall\Core\Data\CourtType; use IQBall\Core\Data\CourtType;
use IQBall\App\Session\SessionHandle;
use IQBall\Core\Data\TacticInfo; use IQBall\Core\Data\TacticInfo;
use IQBall\Core\Gateway\TacticInfoGateway; use IQBall\Core\Gateway\TacticInfoGateway;
use IQBall\Core\Validation\ValidationFail; use IQBall\Core\Validation\ValidationFail;
@ -61,8 +62,8 @@ class TacticModel {
/** /**
* Return the nb last tactics * Return the nb last tactics
*/ */
public function getLast(int $nb): ?array { public function getLast(int $nb, int $ownerId): ?array {
return $this->tactics->getLast($nb); return $this->tactics->getLast($nb, $ownerId);
} }
/** /**

Loading…
Cancel
Save