add activity analyze

merging_APE
Antoine PEREDERII 1 year ago
parent 1b4448fecd
commit a691e2a952

@ -121,8 +121,8 @@ class AthleteController extends BaseController
return $response; return $response;
} }
#[Route(path: '/analyze/{id}', name: 'analyze_details', methods: ['GET'])] #[Route(path: '/analyze', name: 'analyze_details', methods: ['GET'])]
public function activityDetails(): Response public function activityDetails(int $id): Response
{ {
try { try {
// Utilisez $id pour récupérer les détails de l'activité depuis la base de données // Utilisez $id pour récupérer les détails de l'activité depuis la base de données
@ -130,29 +130,16 @@ class AthleteController extends BaseController
// $activityEntity = $activityGateway->getActivityById($id); // Assurez-vous d'avoir une méthode similaire dans votre gateway // $activityEntity = $activityGateway->getActivityById($id); // Assurez-vous d'avoir une méthode similaire dans votre gateway
$analyzeGateway = new AnalyzeGateway(new Connexion(DSN, DB_USER, DB_PASSWORD)); $analyzeGateway = new AnalyzeGateway(new Connexion(DSN, DB_USER, DB_PASSWORD));
$analyzeEntity = $analyzeGateway->getFrequenceCardiaque(); $analyzeEntity = $analyzeGateway->getFrequenceCardiaqueByIdActivity($id);
// $map = new ActivityMapper(); $response = $this->render('./page/analyze.html.twig', [
// $activityModel = $map->activityEntityToModel($activityEntity);
Log::dd($analyzeEntity);
// $listAnalyze = [];
// foreach ($analyzeEntity as $entity) {
// $user = $map->athleteEntityToModel($entity);
// $listUsers[] = ['idathlete' => number_format($user->getId(), 1), 'nom' => $user->getNom(),
// 'prenom' => $user->getPrenom(),'email' => $user->getEmail(), 'sexe' => $user->getSexe(),
// 'taille' => $user->getTaille(), 'poids' => $user->getPoids(), 'motdepasse' => $user->getMotDePasse(),
// 'datenaissance' => $user->getDateNaissance(), 'iscoach' => $user->getRole(), 'img' => 'test',
// 'username' => $user->getUsername()];
// }
$response = $this->render('./page/activity_details.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' => [],
'activity' => [], 'activity' => [],
'analyzes' => $analyzeEntity,
]); ]);
} catch (\Throwable $th) { } catch (\Throwable $th) {
throw $th; throw $th;
@ -211,7 +198,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(),

@ -67,10 +67,7 @@
<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>{{ analyze.effortRessenti }}</td> <td><a href="/analyze?id={{ analyze.idactivity }}">En savoir plus</a></td>
{# <td><a href="/analyze/{{ analyse.effortRessenti }}">En savoir plus</a></td>#}
<td><a href="{{ path('analyze_details', {'id': analyze.effortRessenti }) }}">En savoir plus</a></td>
{# <td><a href="/analyses">En savoir plus</a></td>#}
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>

@ -14,34 +14,60 @@
<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="/home">Home</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 class="card-body">
<div id="map" style="height: 500px;"></div>
<script>
document.addEventListener("DOMContentLoaded", function () {
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>

@ -2,6 +2,8 @@
namespace Database; namespace Database;
use Shared\Log;
class AnalyzeMapper class AnalyzeMapper
{ {
public function analyzeSqlToEntity(array $data):array public function analyzeSqlToEntity(array $data):array

@ -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);
Loading…
Cancel
Save