add loggers actions
This commit is contained in:
parent
59398d14ba
commit
12d4db370f
22 changed files with 517 additions and 218 deletions
|
@ -101,72 +101,7 @@
|
|||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{# Affichage de la fraîcheur des données OSM #}
|
||||
{# {% if stats.osmDataDateMin and stats.osmDataDateMax and stats.osmDataDateAvg %}
|
||||
{% set now = "now"|date("U") %}
|
||||
{% set minDate = stats.osmDataDateMin|date("U") %}
|
||||
{% set maxDate = stats.osmDataDateMax|date("U") %}
|
||||
{% set avgDate = stats.osmDataDateAvg|date("U") %}
|
||||
|
||||
{% set minDiff = now - minDate %}
|
||||
{% set maxDiff = now - maxDate %}
|
||||
{% set avgDiff = now - avgDate %}
|
||||
|
||||
{% set minYears = (minDiff / 31536000)|round(0, 'floor') %}
|
||||
{% set minMonths = ((minDiff % 31536000) / 2592000)|round(0, 'floor') %}
|
||||
{% set maxYears = (maxDiff / 31536000)|round(0, 'floor') %}
|
||||
{% set maxMonths = ((maxDiff % 31536000) / 2592000)|round(0, 'floor') %}
|
||||
{% set avgYears = (avgDiff / 31536000)|round(0, 'floor') %}
|
||||
{% set avgMonths = ((avgDiff % 31536000) / 2592000)|round(0, 'floor') %}
|
||||
|
||||
<div class="row mb-3">
|
||||
<div class="col-12">
|
||||
<div class="alert alert-info osm-freshness-info">
|
||||
<i class="bi bi-clock-history"></i>
|
||||
<strong>Fraîcheur des données OSM :</strong>
|
||||
{% if minYears == maxYears and minMonths == maxMonths %}
|
||||
Toutes les modifications ont été faites il y a
|
||||
{% if minYears > 0 %}
|
||||
{{ minYears }} an{{ minYears > 1 ? 's' : '' }}
|
||||
{% if minMonths > 0 %}, {{ minMonths }} mois{% endif %}
|
||||
{% elseif minMonths > 0 %}
|
||||
{{ minMonths }} mois
|
||||
{% else %}
|
||||
moins d'un mois
|
||||
{% endif %}
|
||||
{% else %}
|
||||
Les modifications ont été faites entre il y a
|
||||
{% if maxYears > 0 %}
|
||||
{{ maxYears }} an{{ maxYears > 1 ? 's' : '' }}
|
||||
{% if maxMonths > 0 %}, {{ maxMonths }} mois{% endif %}
|
||||
{% elseif maxMonths > 0 %}
|
||||
{{ maxMonths }} mois
|
||||
{% else %}
|
||||
moins d'un mois
|
||||
{% endif %}
|
||||
et il y a
|
||||
{% if minYears > 0 %}
|
||||
{{ minYears }} an{{ minYears > 1 ? 's' : '' }}
|
||||
{% if minMonths > 0 %}, {{ minMonths }} mois{% endif %}
|
||||
{% elseif minMonths > 0 %}
|
||||
{{ minMonths }} mois
|
||||
{% else %}
|
||||
moins d'un mois
|
||||
{% endif %},
|
||||
en moyenne il y a
|
||||
{% if avgYears > 0 %}
|
||||
{{ avgYears }} an{{ avgYears > 1 ? 's' : '' }}
|
||||
{% if avgMonths > 0 %}, {{ avgMonths }} mois{% endif %}
|
||||
{% elseif avgMonths > 0 %}
|
||||
{{ avgMonths }} mois
|
||||
{% else %}
|
||||
moins d'un mois
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %} #}
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-3 col-12">
|
||||
|
@ -258,9 +193,8 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="card mt-4">
|
||||
{% include 'admin/stats_history.html.twig' %}
|
||||
<div id="distribution_completion" class="mt-4 mb-4"></div>
|
||||
<div id="distribution_budget_habitant" class="mt-4 mb-4"></div>
|
||||
{% include 'admin/stats_history.html.twig' with {stat: stats} %}
|
||||
<canvas id="distribution_completion" class="mt-4 mb-4" height="600"></canvas>
|
||||
|
||||
|
||||
<div class="row">
|
||||
|
@ -603,8 +537,7 @@
|
|||
}]
|
||||
},
|
||||
options: {
|
||||
responsive: true,
|
||||
maintainAspectRatio: true,
|
||||
responsive: true,
|
||||
plugins: {
|
||||
legend: {
|
||||
position: 'right',
|
||||
|
@ -644,7 +577,7 @@ if(dc ){
|
|||
return ;
|
||||
}
|
||||
new Chart(completionCtx, {
|
||||
type: 'bar',
|
||||
type: 'line',
|
||||
data: {
|
||||
labels: completionLabels,
|
||||
datasets: [{
|
||||
|
@ -661,59 +594,13 @@ if(dc ){
|
|||
beginAtZero: true
|
||||
}
|
||||
},
|
||||
responsive: true,
|
||||
maintainAspectRatio: false
|
||||
responsive: true,
|
||||
}
|
||||
});
|
||||
}else{
|
||||
console.log('pas de distribution_completion')
|
||||
}
|
||||
|
||||
// === Distribution du budget par habitant (écart à la moyenne, pas de 3%) ===
|
||||
const budgetEcartData = [];
|
||||
{% for commerce in stats.places %}
|
||||
{% if commerce.getBudgetParHabitantEcartPourcent is defined %}
|
||||
budgetEcartData.push({{ commerce.getBudgetParHabitantEcartPourcent()|default(0) }});
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
const budgetEcartDistribution = {};
|
||||
budgetEcartData.forEach(ecart => {
|
||||
const range = Math.floor(ecart / 3) * 3;
|
||||
const key = `${range}% à ${range + 3}%`;
|
||||
budgetEcartDistribution[key] = (budgetEcartDistribution[key] || 0) + 1;
|
||||
});
|
||||
const budgetEcartLabels = Object.keys(budgetEcartDistribution).sort((a, b) => parseInt(a) - parseInt(b));
|
||||
const budgetEcartValues = budgetEcartLabels.map(label => budgetEcartDistribution[label]);
|
||||
const dbh = document.getElementById('distribution_budget_habitant');
|
||||
if(dbh){
|
||||
const budgetEcartCtx = dbh.getContext ? dbh.getContext('2d') : null;
|
||||
if(!budgetEcartCtx){
|
||||
console.log('pas de budgetEcartCtx');
|
||||
} else {
|
||||
new Chart(budgetEcartCtx, {
|
||||
type: 'bar',
|
||||
data: {
|
||||
labels: budgetEcartLabels,
|
||||
datasets: [{
|
||||
label: 'Distribution des villes selon l\'écart à la moyenne du budget par habitant (pas 3%)',
|
||||
data: budgetEcartValues,
|
||||
backgroundColor: 'rgba(255, 206, 86, 0.5)',
|
||||
borderColor: 'rgba(255, 206, 86, 1)',
|
||||
borderWidth: 1
|
||||
}]
|
||||
},
|
||||
options: {
|
||||
scales: {
|
||||
y: {
|
||||
beginAtZero: true
|
||||
}
|
||||
},
|
||||
responsive: true,
|
||||
maintainAspectRatio: false
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue