parent
6585a92eb6
commit
1b4448fecd
@ -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,123 @@
|
||||
<?php
|
||||
|
||||
namespace Database;
|
||||
|
||||
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;
|
||||
// }
|
||||
}
|
@ -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,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);
|
Loading…
Reference in new issue