plusieurs courbes de progression

This commit is contained in:
Tykayn 2025-06-19 11:07:54 +02:00 committed by tykayn
parent d9219db84f
commit 123bd8d4d1
2 changed files with 39 additions and 7 deletions

View file

@ -386,11 +386,24 @@ final class AdminController extends AbstractController
$statsHistory->setDate(new \DateTime()) $statsHistory->setDate(new \DateTime())
->setStats($stats); ->setStats($stats);
// Compter les Places avec email et SIRET
$placesWithEmail = 0;
$placesWithSiret = 0;
foreach ($stats->getPlaces() as $place) {
if ($place->getEmail() && $place->getEmail() !== '') {
$placesWithEmail++;
}
if ($place->getSiret() && $place->getSiret() !== '') {
$placesWithSiret++;
}
}
$statsHistory->setPlacesCount($stats->getPlaces()->count()) $statsHistory->setPlacesCount($stats->getPlaces()->count())
->setOpeningHoursCount($stats->getAvecHoraires()) ->setOpeningHoursCount($stats->getAvecHoraires())
->setAddressCount($stats->getAvecAdresse()) ->setAddressCount($stats->getAvecAdresse())
->setWebsiteCount($stats->getAvecSite()) ->setWebsiteCount($stats->getAvecSite())
->setSiretCount($stats->getAvecSiret()) ->setSiretCount($placesWithSiret)
->setEmailsCount($placesWithEmail)
// ->setAccessibiliteCount($stats->getAvecAccessibilite()) // ->setAccessibiliteCount($stats->getAvecAccessibilite())
// ->setNoteCount($stats->getAvecNote()) // ->setNoteCount($stats->getAvecNote())
->setCompletionPercent($stats->getCompletionPercent()) ->setCompletionPercent($stats->getCompletionPercent())

View file

@ -13,19 +13,19 @@ document.addEventListener('DOMContentLoaded', function() {
// Préparer les données pour chaque aspect // Préparer les données pour chaque aspect
const labels = [ const labels = [
{% for stat in statsHistory %} {% for stat in statsHistory|reverse %}
'{{ stat.date|date('d/m/Y') }}'{% if not loop.last %},{% endif %} '{{ stat.date|date('d/m/Y') }}'{% if not loop.last %},{% endif %}
{% endfor %} {% endfor %}
]; ];
const completionData = [ const completionData = [
{% for stat in statsHistory %} {% for stat in statsHistory|reverse %}
{{ stat.completionPercent }}{% if not loop.last %},{% endif %} {{ stat.completionPercent }}{% if not loop.last %},{% endif %}
{% endfor %} {% endfor %}
]; ];
const openingHoursData = [ const openingHoursData = [
{% for stat in statsHistory %} {% for stat in statsHistory|reverse %}
{% if stat.placesCount > 0 %} {% if stat.placesCount > 0 %}
{{ ((stat.openingHoursCount / stat.placesCount) * 100)|round(1) }}{% if not loop.last %},{% endif %} {{ ((stat.openingHoursCount / stat.placesCount) * 100)|round(1) }}{% if not loop.last %},{% endif %}
{% else %} {% else %}
@ -35,7 +35,7 @@ document.addEventListener('DOMContentLoaded', function() {
]; ];
const addressData = [ const addressData = [
{% for stat in statsHistory %} {% for stat in statsHistory|reverse %}
{% if stat.placesCount > 0 %} {% if stat.placesCount > 0 %}
{{ ((stat.addressCount / stat.placesCount) * 100)|round(1) }}{% if not loop.last %},{% endif %} {{ ((stat.addressCount / stat.placesCount) * 100)|round(1) }}{% if not loop.last %},{% endif %}
{% else %} {% else %}
@ -45,7 +45,7 @@ document.addEventListener('DOMContentLoaded', function() {
]; ];
const websiteData = [ const websiteData = [
{% for stat in statsHistory %} {% for stat in statsHistory|reverse %}
{% if stat.placesCount > 0 %} {% if stat.placesCount > 0 %}
{{ ((stat.websiteCount / stat.placesCount) * 100)|round(1) }}{% if not loop.last %},{% endif %} {{ ((stat.websiteCount / stat.placesCount) * 100)|round(1) }}{% if not loop.last %},{% endif %}
{% else %} {% else %}
@ -55,7 +55,7 @@ document.addEventListener('DOMContentLoaded', function() {
]; ];
const siretData = [ const siretData = [
{% for stat in statsHistory %} {% for stat in statsHistory|reverse %}
{% if stat.placesCount > 0 %} {% if stat.placesCount > 0 %}
{{ ((stat.siretCount / stat.placesCount) * 100)|round(1) }}{% if not loop.last %},{% endif %} {{ ((stat.siretCount / stat.placesCount) * 100)|round(1) }}{% if not loop.last %},{% endif %}
{% else %} {% else %}
@ -64,6 +64,16 @@ document.addEventListener('DOMContentLoaded', function() {
{% endfor %} {% endfor %}
]; ];
const emailData = [
{% for stat in statsHistory|reverse %}
{% if stat.placesCount > 0 %}
{{ ((stat.emailsCount / stat.placesCount) * 100)|round(1) }}{% if not loop.last %},{% endif %}
{% else %}
0{% if not loop.last %},{% endif %}
{% endif %}
{% endfor %}
];
new Chart(ctx, { new Chart(ctx, {
type: 'line', type: 'line',
data: { data: {
@ -113,6 +123,15 @@ document.addEventListener('DOMContentLoaded', function() {
tension: 0.3, tension: 0.3,
fill: false, fill: false,
borderWidth: 2 borderWidth: 2
},
{
label: 'Emails (%)',
data: emailData,
borderColor: 'rgb(199, 199, 199)',
backgroundColor: 'rgba(199, 199, 199, 0.1)',
tension: 0.3,
fill: false,
borderWidth: 2
} }
] ]
}, },