diff --git a/gestaoRaul/db.sqlite3 b/gestaoRaul/db.sqlite3
index 35e45a1..4dacca3 100644
Binary files a/gestaoRaul/db.sqlite3 and b/gestaoRaul/db.sqlite3 differ
diff --git a/gestaoRaul/home/__pycache__/urls.cpython-313.pyc b/gestaoRaul/home/__pycache__/urls.cpython-313.pyc
index b030868..48363d0 100644
Binary files a/gestaoRaul/home/__pycache__/urls.cpython-313.pyc and b/gestaoRaul/home/__pycache__/urls.cpython-313.pyc differ
diff --git a/gestaoRaul/home/__pycache__/views.cpython-313.pyc b/gestaoRaul/home/__pycache__/views.cpython-313.pyc
index b933a38..361efe8 100644
Binary files a/gestaoRaul/home/__pycache__/views.cpython-313.pyc and b/gestaoRaul/home/__pycache__/views.cpython-313.pyc differ
diff --git a/gestaoRaul/home/templates/home.html b/gestaoRaul/home/templates/home.html
index 8f9ab30..047cbff 100644
--- a/gestaoRaul/home/templates/home.html
+++ b/gestaoRaul/home/templates/home.html
@@ -29,6 +29,12 @@ RRB&C - DashBoard
diff --git a/gestaoRaul/home/urls.py b/gestaoRaul/home/urls.py
index 3351dac..4016206 100644
--- a/gestaoRaul/home/urls.py
+++ b/gestaoRaul/home/urls.py
@@ -3,6 +3,6 @@ from . import views
urlpatterns = [
path('', views.home, name='home'),
- path('chartCuisine', views.chartCuisine, name='chartCuisine'),
+ path('chartCuisine//', views.chartCuisine, name='chartCuisine'),
]
diff --git a/gestaoRaul/home/views.py b/gestaoRaul/home/views.py
index 71e97c1..9b28b8a 100644
--- a/gestaoRaul/home/views.py
+++ b/gestaoRaul/home/views.py
@@ -4,6 +4,9 @@ from django.db.models import Count, F
from django.http import JsonResponse, HttpResponse
from django.contrib.admin.views.decorators import staff_member_required
from django.contrib.auth.models import User
+from django.utils.dateparse import parse_datetime
+
+import datetime
@@ -29,35 +32,39 @@ def home(request):
@group_required(groupName='Gerente')
-def chartCuisine(request):
- print(request.user.groups.all())
- print(request.user.is_authenticated)
+def chartCuisine(request,dateStart,dateEnd):
+ try:
+ dateStart = parse_datetime(dateStart+' 07:00:00')
+ dateEnd = parse_datetime(dateEnd+' 07:00:00')+ datetime.timedelta(days=1)
+ except:
+ dateStart = parse_datetime('2025-01-01 07:00:00')
+ dateEnd = datetime.datetime.now()
+ # print(request.user.groups.all())
+ # print(request.user.is_authenticated)
# fulano = User()
tFila = []
tPreparando = []
tFinalizado = []
- dataStart = request.GET.get("data-start")
- dataEnd = request.GET.get("data-end")
- orders = Order.objects.filter(delivered__isnull=False)
+ orders = Order.objects.filter(delivered__isnull=False, queue__gt=dateStart, queue__lt=dateEnd)
+ try:
+ for order in orders:
+ tFila.append((order.preparing - order.queue).total_seconds())
+ tPreparando.append((order.finished - order.preparing).total_seconds())
+ tFinalizado.append((order.delivered - order.finished).total_seconds())
- for order in orders:
- tFila.append((order.preparing - order.queue).total_seconds())
- tPreparando.append((order.finished - order.preparing).total_seconds())
- tFinalizado.append((order.delivered - order.finished).total_seconds())
+ mediaFila = int((sum(tFila) / len(tFila))/60)
+ mediaPreparando = int((sum(tPreparando) / len(tPreparando))/60)
+ mediaFinalizado = int((sum(tFinalizado) / len(tFinalizado))/60)
- mediaFila = int((sum(tFila) / len(tFila))/60)
- mediaPreparando = int((sum(tPreparando) / len(tPreparando))/60)
- mediaFinalizado = int((sum(tFinalizado) / len(tFinalizado))/60)
-
- # orders = Order.objects.filter(
- # created_at__gte='a',
- # created_at__lte='b',
- # delivered__isnull=False
- # )
-
- return JsonResponse({
- 'mediaFila': mediaFila,
- 'mediaPreparando': mediaPreparando,
- 'mediaFinalizado': mediaFinalizado,
- })
\ No newline at end of file
+ return JsonResponse({
+ 'mediaFila': mediaFila,
+ 'mediaPreparando': mediaPreparando,
+ 'mediaFinalizado': mediaFinalizado,
+ })
+ except:
+ return JsonResponse({
+ 'mediaFila': 0,
+ 'mediaPreparando': 0,
+ 'mediaFinalizado': 0,
+ })
diff --git a/gestaoRaul/templates/static/home/js/home.js b/gestaoRaul/templates/static/home/js/home.js
index 85c4fdd..00c626a 100644
--- a/gestaoRaul/templates/static/home/js/home.js
+++ b/gestaoRaul/templates/static/home/js/home.js
@@ -38,20 +38,22 @@ new Chart("vendas", {
function mediaCuisine(){
-
+var dateStart = document.getElementById('data-start').value == '' ? '2025-01-01' :document.getElementById('data-start').value;
+var dateEnd = document.getElementById('data-end').value == '' ? '2025-01-15' :document.getElementById('data-end').value;;
var yValues = [];
var xValues = ['Fila', 'Preparando', 'Entregar'];
var barColors = ["red", "green","blue","orange","brown"];
-var resposta = fetch('/chartCuisine', {method: 'GET',
+var resposta = fetch(`/chartCuisine/${dateStart}/${dateEnd}`, {method: 'GET',
headers: {'Content-Type': 'application/json',
},})
.then(response => response.json())
.then(data => {
+ yValues = []
yValues.push(data['mediaFila'])
yValues.push(data['mediaPreparando'])
yValues.push(data['mediaFinalizado'])
-
+ console.log(yValues)
new Chart("cuisine", {
type: "doughnut",
data: {
@@ -76,6 +78,11 @@ var resposta = fetch('/chartCuisine', {method: 'GET',
});
}
+function deleyGraficos(){
+ setTimeout(function() {
+ mediaCuisine();}, 20000);
+}
+// productsPlus()
+mediaCuisine()
-productsPlus()
-mediaCuisine()
\ No newline at end of file
+// console.log(document.getElementById('data-start').value)
\ No newline at end of file