Merge branch 'merged_PLE' of https://codefirst.iut.uca.fr/git/HeartDev/Web into merged_PLE

merged_PLE
Kevin MONTEIRO 1 year ago
commit f237a7986a

@ -4,6 +4,7 @@ namespace App\Controller;
use Database\ActivityGateway; use Database\ActivityGateway;
use Database\ActivityMapper; use Database\ActivityMapper;
use Database\AnalyzeGateway;
use Database\AthleteEntity; use Database\AthleteEntity;
use Database\AthleteMapper; use Database\AthleteMapper;
use Database\EntrainementGateway; use Database\EntrainementGateway;
@ -90,10 +91,13 @@ class AthleteController extends BaseController
} else { } else {
try { try {
$athleteGateway = new AthleteGateway(new Connexion(DSN, DB_USER, DB_PASSWORD)); $athleteGateway = new AthleteGateway(new Connexion(DSN, DB_USER, DB_PASSWORD));
$listSearch = $athleteGateway->getAthlete($username); if($username==null){
$listSearch=$athleteGateway->getAthlete();
} else {
$listSearch = $athleteGateway->getAthleteByName($username);
}
$map = new AthleteMapper(); $map = new AthleteMapper();
$athleteEntity = $map->athleteSqlToEntity($listSearch); $athleteEntity = $map->athleteSqlToEntity($listSearch);
$listUsers = []; $listUsers = [];
foreach ($athleteEntity as $entity) { foreach ($athleteEntity as $entity) {
$user = $map->athleteEntityToModel($entity); $user = $map->athleteEntityToModel($entity);
@ -120,36 +124,25 @@ class AthleteController extends BaseController
return $response; return $response;
} }
#[Route(path: '/analyses', name: 'analyses', methods: ['GET'])] #[Route(path: '/analyze', name: 'analyze_details', methods: ['GET'])]
public function analyses(): Response public function activityDetails(int $id): Response
{ {
try { try {
$activityGateway = new ActivityGateway(new Connexion(DSN, DB_USER, DB_PASSWORD)); // Utilisez $id pour récupérer les détails de l'activité depuis la base de données
$listSearch = $activityGateway->getActivity(); // $activityGateway = new ActivityGateway(new Connexion(DSN, DB_USER, DB_PASSWORD));
$map = new ActivityMapper(); // $activityEntity = $activityGateway->getActivityById($id); // Assurez-vous d'avoir une méthode similaire dans votre gateway
$activityGateway = $map->activitySqlToEntity($listSearch);
$listActivity = []; $analyzeGateway = new AnalyzeGateway(new Connexion(DSN, DB_USER, DB_PASSWORD));
foreach ($activityGateway as $entity) { $analyzeEntity = $analyzeGateway->getFrequenceCardiaqueByIdActivity($id);
$activity = $map->activityEntityToModel($entity);
$listActivity[] = ['idactivity' => number_format($activity->getIdActivity(), 1), 'type' => $activity->getType(),
'date' => $activity->getDate()->format("D j F Y"), 'heureDebut' => $activity->getHeureDebut()->format("H\h i"), 'heureFin' => $activity->getHeureFin()->format("H\h i"),
'effortRessenti' => $activity->getEffortRessenti(), 'variabilite' => $activity->getVariability(), 'variance' => $activity->getVariance(),
'ecartType' => $activity->getStandardDeviation(), 'moyenne' => $activity->getAverage(),
'max' => $activity->getMaximum(), 'min' => $activity->getMinimum(), 'temperature' =>$activity->getAvrTemperature()];
}
$response = $this->render('./page/analyze.html.twig',[ $response = $this->render('./page/analyze.html.twig', [
'css' => $this->preference->getCookie(), 'css' => $this->preference->getCookie(),
'pp' => "test2", 'pp' => "test2",
'user' => 'johndoe',//$currentUser->getUsername(), 'user' => 'johndoe',//$currentUser->getUsername(),
'role' => 'Athlete',//$currentUser->getRole(), 'role' => 'Athlete',//$currentUser->getRole(),
'friendship' => [], 'friendship' => [],
'analyzes' => $listActivity, 'activity' => [],
'mails' => [], 'analyzes' => $analyzeEntity,
'users' => [],
'infoUser' => [],
'exos' => [],
'member' => []
]); ]);
} catch (\Throwable $th) { } catch (\Throwable $th) {
throw $th; throw $th;
@ -158,6 +151,45 @@ class AthleteController extends BaseController
return $response; return $response;
} }
//
// #[Route(path: '/analyses/{id}', name: 'analyses', methods: ['GET'])]
// public function analyses(): Response
// {
// try {
// $activityGateway = new ActivityGateway(new Connexion(DSN, DB_USER, DB_PASSWORD));
// $listSearch = $activityGateway->getActivity();
// $map = new ActivityMapper();
// $activityGateway = $map->activitySqlToEntity($listSearch);
// $listActivity = [];
// foreach ($activityGateway as $entity) {
// $activity = $map->activityEntityToModel($entity);
// $listActivity[] = ['idactivity' => number_format($activity->getIdActivity(), 1), 'type' => $activity->getType(),
// 'date' => $activity->getDate()->format("D j F Y"), 'heureDebut' => $activity->getHeureDebut()->format("H\h i"), 'heureFin' => $activity->getHeureFin()->format("H\h i"),
// 'effortRessenti' => $activity->getEffortRessenti(), 'variabilite' => $activity->getVariability(), 'variance' => $activity->getVariance(),
// 'ecartType' => $activity->getStandardDeviation(), 'moyenne' => $activity->getAverage(),
// 'max' => $activity->getMaximum(), 'min' => $activity->getMinimum(), 'temperature' =>$activity->getAvrTemperature()];
// }
//
// $response = $this->render('./page/analyze.html.twig',[
// 'css' => $this->preference->getCookie(),
// 'pp' => "test2",
// 'user' => 'johndoe',//$currentUser->getUsername(),
// 'role' => 'Athlete',//$currentUser->getRole(),
// 'friendship' => [],
// 'analyzes' => $listActivity,
// 'mails' => [],
// 'users' => [],
// 'infoUser' => [],
// 'exos' => [],
// 'member' => []
// ]);
// } catch (\Throwable $th) {
// throw $th;
// return $this->render("./page/analyze.html.twig", ['tabError' => $taberror]);
// }
// return $response;
// }
#[Route(path: '/activity', name: 'activity', methods: ['GET'])] #[Route(path: '/activity', name: 'activity', methods: ['GET'])]
public function activity(): Response public function activity(): Response
{ {
@ -169,7 +201,7 @@ class AthleteController extends BaseController
$listActivity = []; $listActivity = [];
foreach ($activityGateway as $entity) { foreach ($activityGateway as $entity) {
$activity = $map->activityEntityToModel($entity); $activity = $map->activityEntityToModel($entity);
$listActivity[] = ['idactivity' => number_format($activity->getIdActivity(), 1), 'type' => $activity->getType(), $listActivity[] = ['idactivity' => number_format($activity->getIdActivity()), 'type' => $activity->getType(),
'date' => $activity->getDate()->format("D j F Y"), 'heureDebut' => $activity->getHeureDebut()->format("H\h i"), 'heureFin' => $activity->getHeureFin()->format("H\h i"), 'date' => $activity->getDate()->format("D j F Y"), 'heureDebut' => $activity->getHeureDebut()->format("H\h i"), 'heureFin' => $activity->getHeureFin()->format("H\h i"),
'effortRessenti' => $activity->getEffortRessenti(), 'variabilite' => $activity->getVariability(), 'variance' => $activity->getVariance(), 'effortRessenti' => $activity->getEffortRessenti(), 'variabilite' => $activity->getVariability(), 'variance' => $activity->getVariance(),
'ecartType' => $activity->getStandardDeviation(), 'moyenne' => $activity->getAverage(), 'ecartType' => $activity->getStandardDeviation(), 'moyenne' => $activity->getAverage(),

@ -7,6 +7,7 @@ use App\Router\Request\IRequest;
use App\Router\Response\Response; use App\Router\Response\Response;
use App\Router\Response\IResponse; use App\Router\Response\IResponse;
use Manager\DataManager;
use Shared\Attributes\Route; use Shared\Attributes\Route;
use Twig\Environment; use Twig\Environment;
use Data\Core\Preferences; use Data\Core\Preferences;
@ -16,16 +17,16 @@ use Shared\Log;
class CoachController extends BaseController class CoachController extends BaseController
{ {
private ICoachManager $coachManager; // private ICoachManager $coachManager;
private $security; // private $security;
private Environment $twig; // private Environment $twig;
protected Preferences $preference; protected Preferences $preference;
public function __construct(DataManager $dataManager, Security $security) public function __construct()
{ {
session_start(); // session_start();
$this->coachManager = $dataManager->coachMgr; // $this->coachManager = $dataManager->coachMgr;
$this->security = $security; // $this->security = $security;
$this->preference = new Preferences(); $this->preference = new Preferences();
} }

@ -18,7 +18,6 @@ class HeartRateController extends BaseController
public function __construct() public function __construct()
{ {
session_start();
$this->preference = new Preferences(); $this->preference = new Preferences();
} }

@ -9,6 +9,8 @@ use Shared\Attributes\Route;
use Twig\Environment; use Twig\Environment;
use Data\Core\Preferences; use Data\Core\Preferences;
use Shared\Log; use Shared\Log;
use Database\Athletegateway;
use Database\Connexion;
class UserController extends BaseController class UserController extends BaseController
{ {
@ -43,6 +45,28 @@ class UserController extends BaseController
#[Route(path: '/home', name: 'home', methods: ['GET'])] #[Route(path: '/home', name: 'home', methods: ['GET'])]
public function home(): Response public function home(): Response
{ {
$athleteGateway = new AthleteGateway(new Connexion(DSN, DB_USER, DB_PASSWORD));
$activity = $athleteGateway->getListActivity('1');//$currentUser->getId()
// Log::dd($activity);
$chart = [];
foreach($activity as $act){
$chart[] = ['act' => $act['nbactivite'], 'mois' => date('m', $act['mois'])];
}
// $activityGateway = new ActivityGateway(new Connexion(DSN, DB_USER, DB_PASSWORD));
// $listSearch = $activityGateway->getActivity();
// $map = new ActivityMapper();
// $activityGateway = $map->activitySqlToEntity($listSearch);
// $listActivity = [];
// foreach ($activityGateway as $entity) {
// $activity = $map->activityEntityToModel($entity);
// $listActivity[] = ['idactivity' => number_format($activity->getIdActivity()), 'type' => $activity->getType(),
// 'date' => $activity->getDate()->format("D j F Y"), 'heureDebut' => $activity->getHeureDebut()->format("H\h i"), 'heureFin' => $activity->getHeureFin()->format("H\h i"),
// 'effortRessenti' => $activity->getEffortRessenti(), 'variabilite' => $activity->getVariability(), 'variance' => $activity->getVariance(),
// 'ecartType' => $activity->getStandardDeviation(), 'moyenne' => $activity->getAverage(),
// 'max' => $activity->getMaximum(), 'min' => $activity->getMinimum(), 'temperature' => $activity->getAvrTemperature()];
// }
// Log::dd($chart);
return $this->render('./page/home.html.twig',[ return $this->render('./page/home.html.twig',[
'css' => $this->preference->getCookie(), 'css' => $this->preference->getCookie(),
'pp' => "test2", 'pp' => "test2",
@ -50,6 +74,7 @@ class UserController extends BaseController
'role' => "Athlète", 'role' => "Athlète",
'friendship' => [], 'friendship' => [],
'analyzes' => [], 'analyzes' => [],
'chart' => $chart,
'mails' => [], 'mails' => [],
'users' => [], 'users' => [],
'infoUser' => [], 'infoUser' => [],

@ -67,8 +67,8 @@
<td>{{analyze.max}} Bpm</td> <td>{{analyze.max}} Bpm</td>
<td>{{analyze.min}} Bpm</td> <td>{{analyze.min}} Bpm</td>
<td>{{analyze.temperature}} °C</td> <td>{{analyze.temperature}} °C</td>
{# <td><a href="{{ path('analyze_details', {'id': analyze.id}) }}">En savoir plus</a></td>#} <td>{{analyze.idactivity}} °C</td>
<td><a href="/analyses">En savoir plus</a></td> <td><a href="/analyze?id={{ analyze.idactivity }}">En savoir plus</a></td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>

@ -14,34 +14,135 @@
<ol class="breadcrumb mb-4"> <ol class="breadcrumb mb-4">
<li class="breadcrumb-item"><a href="/home">Accueil</a></li> <li class="breadcrumb-item"><a href="/home">Accueil</a></li>
<li class="breadcrumb-item active">Exercices</li> <li class="breadcrumb-item active">Exercices</li>
<script src="https://unpkg.com/leaflet/dist/leaflet.js"></script>
</ol> </ol>
<div class="card-body"> <div class="card-body">
<div class="datatable-container"> <table id="datatablesSimple" class="datatable-table">
<form method="post" action="/exercices"> <thead>
Type : <input type="text" name="type"/>
Intensité : <input type="text" name="intensite"/>
Date : <input type="text" name="date"/>
<button class="btn btn-primary btn-mrg" id="btnNavbarSearch" type="submit">Ajouter l'exercice</button>
</form>
</div>
{% for analyze in analyzes %}
<tr> <tr>
<td>{{analyze.date}}</td> <th>id FC</th>
<td>{{analyze.heureDebut}}</td> <th>altitude</th>
<td>{{analyze.heureFin}}</td> <th>temps</th>
<td>{{analyze.type}}</td> <th>Temperature</th>
<td>{{analyze.effortRessenti}}</td> <th>bpm</th>
<td>{{analyze.variabilite}}</td> <th>longitude</th>
<td>{{analyze.variance}}</td> <th>latitude</th>
<td>{{analyze.ecartType}}</td> <th>activiteid</th>
<td>{{analyze.moyenne}} Bpm</td> <th></th>
<td>{{analyze.max}} Bpm</td>
<td>{{analyze.min}} Bpm</td>
<td>{{analyze.temperature}} °C</td>
<td><a href="/analyses">En savoir plus</a></td>
</tr> </tr>
{% endfor %} </thead>
{% for analyze in analyzes %}
<tbody>
<tr>
<td>{{analyze.idfc}}</td>
<td>{{analyze.altitude}}</td>
<td>{{analyze.temps}}</td>
<td>{{analyze.temperature}}</td>
<td>{{analyze.bpm}}</td>
<td>{{analyze.longitude}}</td>
<td>{{analyze.latitude}}</td>
<td>{{analyze.activiteid}}</td>
<td><a href="/home">Home</a></td>
</tr>
</tbody>
{% endfor %}
</table>
{# <div>#}
{# <canvas id="myChart" width="400" height="200">#}
{# <p>Hello Fallback World</p>#}
{# </canvas>#}
{# </div>#}
{# <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>#}
{# <script>#}
{# const ctx = document.getElementById('myChart');#}
{# new Chart(ctx, {#}
{# type: 'line',#}
{# data: {#}
{# labels: [#}
{# {% for analyze in analyzes %}#}
{# {{analyze.temps}}#}
{# {% endfor %}#}
{# ],#}
{# datasets: [{#}
{# label: 'Batement par minute',#}
{# data: [#}
{# {% for analyze in analyzes %}#}
{# {{analyze.bpm}}#}
{# {% endfor %}#}
{# ],#}
{# borderWidth: 1#}
{# }]#}
{# },#}
{# options: {#}
{# scales: {#}
{# y: {#}
{# beginAtZero: true#}
{# }#}
{# }#}
{# }#}
{# });#}
{# </script>#}
<div>
<canvas id="myChart" width="400" height="200">
<p>Hello Fallback World</p>
</canvas>
</div>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script>
const ctx = document.getElementById('myChart');
const labels = [
{% for analyze in analyzes %}
'{{ analyze.temps }}',
{% endfor %}
];
const data = [
{% for analyze in analyzes %}
{{ analyze.bpm }},
{% endfor %}
];
new Chart(ctx, {
type: 'line',
data: {
labels: labels,
datasets: [{
label: 'Batement par minute',
data: data,
borderWidth: 1
}]
},
options: {
scales: {
y: {
beginAtZero: false
}
}
}
});
</script>
<div class="card-body">
<div id="map" style="height: 500px;"></div>
<script>
document.addEventListener("DOMContentLoaded", function () {
{#var lat = {{ analyze.latitude }}#}
var map = L.map('map').setView([45.75771709151474, 3.113484980409329], 14);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© OpenStreetMap contributors'
}).addTo(map);
{% for analyze in analyzes %}
var marker = L.marker([{{ analyze.latitude }}, {{ analyze.longitude }}]).addTo(map);
marker.bindPopup(`
<strong>Date:</strong> {{ analyze.temps }}<br>
<strong>FC:</strong> {{ analyze.bpm }}<br>
<strong>Altitude:</strong> {{ analyze.altitude }}<br>
<strong>Temperature:</strong> {{ analyze.temperature }}
`);
{% endfor %}
});
</script>
</div>
</div> </div>
</div> </div>
</div> </div>

@ -21,7 +21,7 @@
<button class="btn btn-primary btn-mrg" id="btnNavbarSearch" type="submit">Ajouter un exercice</button> <button class="btn btn-primary btn-mrg" id="btnNavbarSearch" type="submit">Ajouter un exercice</button>
</form> </form>
<div class="card-body"> <div class="card-body">
<div class="datatable-container"> <div class="datatable-container">
<table id="datatablesSimple" class="datatable-table"> <table id="datatablesSimple" class="datatable-table">
<thead> <thead>
<tr> <tr>

@ -21,8 +21,55 @@
<i class="fas fa-chart-area me-1"></i> <i class="fas fa-chart-area me-1"></i>
Stastiques globales Stastiques globales
</div> </div>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<div class="card-body"> <div class="card-body">
{# <canvas id="myAreaChart" width="100%" height="40"></canvas> #} <canvas id="myChart" width="100%" height="40">
</canvas>
<script>
document.addEventListener("DOMContentLoaded", function () {
const ctx = document.getElementById('myAreaChart').getContext('2d');
const myChart = new Chart(ctx, {
type: 'line',
data: {
labels: chart.map(entry => entry.mois),
datasets: [{
label: 'Nombre d\'activité',
data: {
{% for analyze in analyzes %}
{{ chart.act }},
{{ chart.mois }},
{% endfor %}
},
fill: false
}]
}
});
});
</script>
{# <script>#}
{# const ctx = document.getElementById('myChart');#}
{# new Chart(ctx, {#}
{# type: 'bar',#}
{# data: {#}
{# labels: ['Red', 'Blue', 'Yellow', 'Green', 'Purple', 'Orange'],#}
{# datasets: [{#}
{# label: '# of Votes',#}
{# data: [12, 19, 3, 5, 2, 3],#}
{# borderWidth: 1#}
{# }]#}
{# },#}
{# options: {#}
{# scales: {#}
{# y: {#}
{# beginAtZero: true#}
{# }#}
{# }#}
{# }#}
{# });#}
{# </script>#}
</div> </div>
</div> </div>
</div> </div>

@ -17,7 +17,7 @@ class ActivityGateway {
public function getActivityById(int $activityId) { public function getActivityById(int $activityId) {
$query = "SELECT * FROM Activite WHERE idActivite = :id"; $query = "SELECT * FROM Activite WHERE idActivite = :id";
$params = [':id' => [$activityId, PDO::PARAM_INT]]; $params = [':id' => $activityId];
return $this->connection->executeWithErrorHandling($query, $params); return $this->connection->executeWithErrorHandling($query, $params);
} }

@ -0,0 +1,79 @@
<?php
namespace Database;
class AnalyzeEntity
{
private $idFc;
private $altitude;
private $time;
private $temperature;
private $bpm;
private $longitude;
private $latitude;
private $idactivity;
public function getIdFC()
{
return $this->idFc;
}
public function getAltitude()
{
return $this->altitude;
}
public function getTime()
{
return $this->temps;
}
public function getTemperature()
{
return $this->temperature;
}
public function getBpm()
{
return $this->bpm;
}
public function getLongitude()
{
return $this->longitude;
}
public function getLatitude()
{
return $this->latitude;
}
public function getIdActivity()
{
return $this->idactivity;
}
public function setIdFC($idFc)
{
$this->idFc = $idFc;
}
public function setAltitude($altitude)
{
$this->altitude = $altitude;
}
public function setTime($time)
{
$this->time = $time;
}
public function setTemperature($temperature)
{
$this->temperature = $temperature;
}
public function setBpm($bpm)
{
$this->bpm = $bpm;
}
public function setLongitude($longitude)
{
$this->longitude = $longitude;
}
public function setLatitude($latitude)
{
$this->latitude = $latitude;
}
public function setIdActivity($idactivity)
{
$this->idactivity = $idactivity;
}
}

@ -0,0 +1,24 @@
<?php
namespace Database;
class AnalyzeGateway
{
private Connexion $connection;
public function __construct(Connexion $connection) {
$this->connection = $connection;
}
public function getFrequenceCardiaque() {
$query = "SELECT * FROM FrequenceCardiaque";
return $this->connection->executeWithErrorHandling($query);
}
public function getFrequenceCardiaqueByIdActivity(int $activityId)
{
$query = "SELECT * FROM FrequenceCardiaque WHERE activiteid = :id";
$params = [':id' => $activityId];
return $this->connection->executeWithErrorHandling($query, $params);
}
}

@ -0,0 +1,125 @@
<?php
namespace Database;
use Shared\Log;
class AnalyzeMapper
{
public function analyzeSqlToEntity(array $data):array
{
$analyzeEntities = [];
foreach ($data as $analyzeData) {
$analyze = new ActivityEntity();
if (isset($analyzeData['idactivite'])) {
$analyze->setIdActivity($analyzeData['idactivite']);
}
if (isset($analyzeData['type'])) {
$analyze->setType($analyzeData['type']);
}
if (isset($analyzeData['date'])) {
$analyze->setDate($analyzeData['date']);
}
if (isset($analyzeData['heurededebut'])) {
$analyze->setHeureDebut($analyzeData['heurededebut']);
}
if (isset($analyzeData['heuredefin'])) {
$analyze->setHeureFin($analyzeData['heuredefin']);
}
if (isset($analyzeData['effortressent'])) {
$analyze->setEffortRessenti($analyzeData['effortressent']);
}
if (isset($analyzeData['variabilite'])) {
$analyze->setVariabilite($analyzeData['variabilite']);
}
if (isset($analyzeData['variance'])) {
$analyze->setVariance($analyzeData['variance']);
}
if (isset($analyzeData['ecarttype'])) {
$analyze->setEcartType($analyzeData['ecarttype']);
}
if (isset($analyzeData['moyenne'])) {
$analyze->setMoyenne($analyzeData['moyenne']);
}
if (isset($analyzeData['maximum'])) {
$analyze->setMaximum($analyzeData['maximum']);
}
if (isset($analyzeData['minimum'])) {
$analyze->setMinimum($analyzeData['minimum']);
}
if (isset($analyzeData['temperaturemoyenne'])) {
$analyze->setTemperatureMoyenne($analyzeData['temperaturemoyenne']);
}
$analyzeEntities[] = $analyze;
}
return $analyzeEntities;
}
/**
* @throws \Exception
*/
// public function ActivityEntityToModel(ActivityEntity $activiteEntity):Activity {
// $date = new DateTime($activiteEntity->getDate());
// $heureDebut = new \DateTime($activiteEntity->getHeureDebut());
// $heureFin = new \DateTime($activiteEntity->getHeureFin());
// $effortRessenti = intval($activiteEntity->getEffortRessenti());
// $variability = floatval($activiteEntity->getVariability());
// $variance = floatval($activiteEntity->getVariance());
// $ecartType = floatval($activiteEntity->getEcartType());
//
// $act = new Activity(
// $activiteEntity->getIdActivity(),
// $activiteEntity->getType(),
// $date,
// $heureDebut,
// $heureFin,
// $effortRessenti,
// $variability,
// $variance,
// $ecartType,
// $activiteEntity->getMoyenne(),
// $activiteEntity->getMaximum(),
// $activiteEntity->getMinimum(),
// $activiteEntity->getTemperatureMoyenne(),
// 'false'
// );
//
// return $act;
// }
//public function ActivityToEntity(Activity model): ActivityEntity;
// public function activityToEntity( $act):ActivityEntity{
//
// $act = new ActivityEntity();
// $act->setIdActivity($act->getIdActivity()());
// $act->setType($act->getType());
// $act->setDate($act->getDate());
// $act->setHeureDebut($act->getHeureDebut());
// $act->setHeureFin($act->getHeureFin());
// $act->setEffortRessenti($act->getEffortRessenti());
// $act->setVariabilite($act->getVariability());
// $act->setVariance($act->getVariance());
// $act->setEcartType($act->getEcartType());
// $act->setMoyenne($act->getMoyenne());
// $act->setMaximum($act->getMaximum());
// $act->setMinimum($act->getMinimum());
// $act->setTemperatureMoyenne($act->getTemperatureMoyenne());
//
// return $act;
// }
}

@ -30,7 +30,7 @@ class AthleteGateway {
public function getAthleteByName(string $name): array public function getAthleteByName(string $name): array
{ {
$query = "SELECT * FROM Athlete WHERE nom = :name AND isCoach=FALSE"; $query = "SELECT * FROM Athlete WHERE nom = :name AND isCoach=FALSE";
$params = [':name' => [$name, PDO::PARAM_STR]]; $params = [':name' => $name];
return $this->connection->executeWithErrorHandling($query, $params); return $this->connection->executeWithErrorHandling($query, $params);
} }
@ -87,6 +87,23 @@ class AthleteGateway {
return $this->connection->executeWithErrorHandling($query, $params); return $this->connection->executeWithErrorHandling($query, $params);
} }
public function getListActivity(int $idAthlete): array
{
$query = "SELECT count(ac.idActivite) AS nbActivite, EXTRACT(MONTH FROM ac.date) AS mois
FROM Athlete at, Activite ac
WHERE at.idAthlete = :idAthlete
AND ac.date > CURRENT_DATE - INTERVAL '1 YEAR'
AND ac.athleteId = at.idAthlete
GROUP BY mois";
$params = [
':idAthlete' => $idAthlete,
];
return $this->connection->executeWithErrorHandling($query, $params);
}
public function addAthlete(AthleteEntity $athlete): array public function addAthlete(AthleteEntity $athlete): array
{ {
$query = "INSERT INTO Athlete (nom, prenom, email, sexe, taille, poids, motDePasse, dateNaissance, isCoach) $query = "INSERT INTO Athlete (nom, prenom, email, sexe, taille, poids, motDePasse, dateNaissance, isCoach)

@ -14,8 +14,8 @@ class AthleteMapper {
foreach ($data as $athleteData) { foreach ($data as $athleteData) {
$athlete = new AthleteEntity(); $athlete = new AthleteEntity();
if (isset($athleteData['idathlete'])) { if (isset($athleteData['idAthlete'])) {
$athlete->setIdAthlete($athleteData['idathlete']); $athlete->setIdAthlete($athleteData['idAthlete']);
} }
if (isset($athleteData['nom'])) { if (isset($athleteData['nom'])) {
@ -46,16 +46,16 @@ class AthleteMapper {
$athlete->setPoids($athleteData['poids']); $athlete->setPoids($athleteData['poids']);
} }
if (isset($athleteData['motdepasse'])) { if (isset($athleteData['motDePasse'])) {
$athlete->setMotDePasse($athleteData['motdepasse']); $athlete->setMotDePasse($athleteData['motDePasse']);
} }
if (isset($athleteData['datenaissance'])) { if (isset($athleteData['dateNaissance'])) {
$athlete->setDateNaissance($athleteData['datenaissance']); $athlete->setDateNaissance($athleteData['dateNaissance']);
} }
if (isset($athleteData['iscoach'])) { if (isset($athleteData['isCoach'])) {
$athlete->setIsCoach($athleteData['iscoach']); $athlete->setIsCoach($athleteData['isCoach']);
} }
$athleteEntities[] = $athlete; $athleteEntities[] = $athlete;

@ -20,8 +20,8 @@ class NotificationGateway
} }
public function addNotification(NotificationEntity $notif){ public function addNotification(NotificationEntity $notif){
$query = "INSERT INTO Notification (idnotif, message, date, statut, urgence, athleteid) VALUES (:idNotif, :message, :date, :statut, :urgence, :idAthlete)"; $query = "INSERT INTO Notification (message, date, statut, urgence, athleteid) VALUES (:message, :date, :statut, :urgence, :idAthlete)";
$params = [':idNotif'=>$notif->getIdNotif(), ':message'=>$notif->getMessage(), ':date'=>$notif->getDate(), ':statut'=>$notif->getStatut(), ':urgence'=>$notif->getUrgence(), ':idAthlete'=>$notif->getIdAthlete()]; $params = [':message'=>$notif->getMessage(), ':date'=>$notif->getDate(), ':statut'=>$notif->getStatut(), ':urgence'=>$notif->getUrgence(), ':idAthlete'=>$notif->getIdAthlete()];
return $this->connection->executeWithErrorHandling($query, $params); return $this->connection->executeWithErrorHandling($query, $params);
} }
} }

@ -0,0 +1,6 @@
INSERT INTO Athlete (idAthlete, username, nom, prenom, email, sexe, taille, poids, motDePasse, dateNaissance, isCoach) VALUES
(1, 'johnD63', 'Doe', 'John', 'john.doe@example.com', 'M', 1.80, 70, 'password123', '1990-01-01', FALSE),
(2, 'janeS03', 'Smith', 'Jane', 'jane.smith@example.com', 'F', 1.65, 60, 'password456', '1992-02-02', TRUE),
(3, 'bryanO', 'OConner', 'Bryan', 'bryan.oconner@example.com', 'M', 1.88, 86, 'password789', '1973-09-12', FALSE),
(4, 'dominicT', 'Toretto', 'Dominic', 'dominic.toretto@example.com', 'M', 1.83, 94, 'password987', '1967-07-18', TRUE),
(5, 'miaT', 'Toretto', 'Mia', 'mia.toretto@example.com', 'F', 1.70, 56, 'password654', '1980-04-26', FALSE);

@ -0,0 +1,21 @@
INSERT INTO FrequenceCardiaque VALUES(1, 100, '08:15:00', 15, 130, 45.75771709151474, 3.113484980409329, 1);
INSERT INTO FrequenceCardiaque VALUES
(2, ROUND(RANDOM() * 10 + 90), '08:16:00', ROUND(RANDOM() * 5 + 10), ROUND(RANDOM() * 20 + 110), 45.75772709151474, 3.113494980409329, 1),
(3, ROUND(RANDOM() * 10 + 90), '08:17:00', ROUND(RANDOM() * 5 + 10), ROUND(RANDOM() * 20 + 110), 45.75773709151474, 3.113504980409329, 1),
(4, ROUND(RANDOM() * 10 + 90), '08:18:00', ROUND(RANDOM() * 5 + 10), ROUND(RANDOM() * 20 + 110), 45.75774709151474, 3.113514980409329, 1),
(5, ROUND(RANDOM() * 10 + 90), '08:19:00', ROUND(RANDOM() * 5 + 10), ROUND(RANDOM() * 20 + 110), 45.75775709151474, 3.113524980409329, 1),
(6, ROUND(RANDOM() * 10 + 90), '08:20:00', ROUND(RANDOM() * 5 + 10), ROUND(RANDOM() * 20 + 110), 45.75776709151474, 3.113534980409329, 1),
(7, ROUND(RANDOM() * 10 + 90), '08:21:00', ROUND(RANDOM() * 5 + 10), ROUND(RANDOM() * 20 + 110), 45.75777709151474, 3.113544980409329, 1),
(8, ROUND(RANDOM() * 10 + 90), '08:22:00', ROUND(RANDOM() * 5 + 10), ROUND(RANDOM() * 20 + 110), 45.75778709151474, 3.113554980409329, 1),
(9, ROUND(RANDOM() * 10 + 90), '08:23:00', ROUND(RANDOM() * 5 + 10), ROUND(RANDOM() * 20 + 110), 45.75779709151474, 3.113564980409329, 1),
(10, ROUND(RANDOM() * 10 + 90), '08:24:00', ROUND(RANDOM() * 5 + 10), ROUND(RANDOM() * 20 + 110), 45.75780709151474, 3.113574980409329, 1),
(11, ROUND(RANDOM() * 10 + 90), '08:25:00', ROUND(RANDOM() * 5 + 10), ROUND(RANDOM() * 20 + 110), 45.75781709151474, 3.113584980409329, 1),
(12, ROUND(RANDOM() * 10 + 90), '08:26:00', ROUND(RANDOM() * 5 + 10), ROUND(RANDOM() * 20 + 110), 45.75782709151474, 3.113594980409329, 1),
(13, ROUND(RANDOM() * 10 + 90), '08:27:00', ROUND(RANDOM() * 5 + 10), ROUND(RANDOM() * 20 + 110), 45.75783709151474, 3.113604980409329, 1),
(14, ROUND(RANDOM() * 10 + 90), '08:28:00', ROUND(RANDOM() * 5 + 10), ROUND(RANDOM() * 20 + 110), 45.75784709151474, 3.113614980409329, 1),
(15, ROUND(RANDOM() * 10 + 90), '08:29:00', ROUND(RANDOM() * 5 + 10), ROUND(RANDOM() * 20 + 110), 45.75785709151474, 3.113624980409329, 1),
(16, ROUND(RANDOM() * 10 + 90), '08:30:00', ROUND(RANDOM() * 5 + 10), ROUND(RANDOM() * 20 + 110), 45.75786709151474, 3.113634980409329, 1),
(17, ROUND(RANDOM() * 10 + 90), '08:31:00', ROUND(RANDOM() * 5 + 10), ROUND(RANDOM() * 20 + 110), 45.75787709151474, 3.113644980409329, 1),
(18, ROUND(RANDOM() * 10 + 90), '08:32:00', ROUND(RANDOM() * 5 + 10), ROUND(RANDOM() * 20 + 110), 45.75788709151474, 3.113654980409329, 1),
(19, ROUND(RANDOM() * 10 + 90), '08:33:00', ROUND(RANDOM() * 5 + 10), ROUND(RANDOM() * 20 + 110), 45.75789709151474, 3.113664980409329, 1),
(20, ROUND(RANDOM() * 10 + 90), '08:34:00', ROUND(RANDOM() * 5 + 10), ROUND(RANDOM() * 20 + 110), 45.75790709151474, 3.113674980409329, 1);

@ -0,0 +1,29 @@
INSERT INTO Friendship (idAthlete1, idAthlete2, debut) VALUES
(3, 4, '2023-01-01'),
(3, 5, '2023-01-12');
INSERT INTO Notification (idNotif, message, date, statut, urgence, athleteId) VALUES
(1, 'Training session at 10 AM', '2023-03-10', TRUE, 1, 1),
(2, 'Training session at 3 PM', '2023-05-10', TRUE, 1, 2);
INSERT INTO Statistique (idStatistique, poids, fcMoyenne, fcMax, caloriesBruleesMoy, date, athleteId) VALUES
(1, 70, 80, 150, 500, '2023-03-10', 1),
(2, 86, 95, 170, 896, '2023-04-13', 3);
INSERT INTO Entrainement (idEntrainement, date, description, latitude, longitude, feedback, athleteId) VALUES
(1, '2023-03-10', 'Long run in the park', 40.7128, -74.0060, 'Good effort', 1),
(2, '2023-04-13', 'Long run in the forest', 44.7128, -70.0060, 'Pretty good effort', 3);
INSERT INTO Participe (athleteId, entrainementId) VALUES
(1, 1),
(3, 2);
INSERT INTO SourceDonnee (idSource, type, modele, precision2, athleteId) VALUES
(1, 'Heart Rate Monitor', 'HRM-Pro', 98.5, 1);
INSERT INTO Activite (idActivite, type, date, heureDeDebut, heureDeFin, effortRessent, variabilite, variance, ecartType, moyenne, maximum, minimum, temperatureMoyenne, athleteId, sourceId) VALUES
(1, 'Running', '2023-03-10', '08:00:00', '09:00:00', 3, 0.5, 1, 0.1, 140, 160, 120, 20, 1, 1),
(2, 'Running Forest', '2023-04-13', '10:00:00', '12:00:00', 5, 0.5, 1, 0.1, 140, 160, 120, 20, 1, 1);
INSERT INTO FrequenceCardiaque (idFc, altitude, temps, temperature, bpm, longitude, latitude, activiteId) VALUES
(1, 100, '08:15:00', 15, 130, -74.0060, 40.7128, 1);

@ -103,30 +103,5 @@ CREATE TABLE FrequenceCardiaque (
FOREIGN KEY (activiteId) REFERENCES Activite(idActivite) FOREIGN KEY (activiteId) REFERENCES Activite(idActivite)
); );
INSERT INTO Athlete (idAthlete, nom, prenom, email, sexe, taille, poids, motDePasse, dateNaissance, isCoach) VALUES \i athlete.sql
(1, 'Doe', 'John', 'john.doe@example.com', 'M', 1.80, 70, 'password123', '1990-01-01', FALSE), \i friendship.sql
(2, 'Smith', 'Jane', 'jane.smith@example.com', 'F', 1.65, 60, 'password456', '1992-02-02', TRUE);
INSERT INTO Friendship (idAthlete1, idAthlete2, debut) VALUES
(1, 2, '2023-01-01');
INSERT INTO Notification (idNotif, message, date, statut, urgence, athleteId) VALUES
(1, 'Training session at 10 AM', '2023-03-10', TRUE, 1, 1);
INSERT INTO Statistique (idStatistique, poids, fcMoyenne, fcMax, caloriesBruleesMoy, date, athleteId) VALUES
(1, 70, 80, 150, 500, '2023-03-10', 1);
INSERT INTO Entrainement (idEntrainement, date, description, latitude, longitude, feedback, athleteId) VALUES
(1, '2023-03-12', 'Long run in the park', 40.7128, -74.0060, 'Good effort', 1);
INSERT INTO Participe (athleteId, entrainementId) VALUES
(1, 1);
INSERT INTO SourceDonnee (idSource, type, modele, precision2, athleteId) VALUES
(1, 'Heart Rate Monitor', 'HRM-Pro', 98.5, 1);
INSERT INTO Activite (idActivite, type, date, heureDeDebut, heureDeFin, effortRessent, variabilite, variance, ecartType, moyenne, maximum, minimum, temperatureMoyenne, athleteId, sourceId) VALUES
(1, 'Running', '2023-03-10', '08:00:00', '09:00:00', 7, 0.5, 1, 0.1, 140, 160, 120, 20, 1, 1);
INSERT INTO FrequenceCardiaque (idFc, altitude, temps, temperature, bpm, longitude, latitude, activiteId) VALUES
(1, 100, '08:15:00', 15, 130, -74.0060, 40.7128, 1);

28
package-lock.json generated

@ -0,0 +1,28 @@
{
"name": "Web",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"dependencies": {
"chart.js": "^4.4.1"
}
},
"node_modules/@kurkle/color": {
"version": "0.3.2",
"resolved": "https://registry.npmjs.org/@kurkle/color/-/color-0.3.2.tgz",
"integrity": "sha512-fuscdXJ9G1qb7W8VdHi+IwRqij3lBkosAm4ydQtEmbY58OzHXqQhvlxqEkoz0yssNVn38bcpRWgA9PP+OGoisw=="
},
"node_modules/chart.js": {
"version": "4.4.1",
"resolved": "https://registry.npmjs.org/chart.js/-/chart.js-4.4.1.tgz",
"integrity": "sha512-C74QN1bxwV1v2PEujhmKjOZ7iUM4w6BWs23Md/6aOZZSlwMzeCIDGuZay++rBgChYru7/+QFeoQW0fQoP534Dg==",
"dependencies": {
"@kurkle/color": "^0.3.0"
},
"engines": {
"pnpm": ">=7"
}
}
}
}

@ -0,0 +1,5 @@
{
"dependencies": {
"chart.js": "^4.4.1"
}
}
Loading…
Cancel
Save