Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -2,16 +2,14 @@ from streamlit_calendar import calendar
|
|
2 |
import streamlit as st
|
3 |
from datetime import datetime
|
4 |
from zoneinfo import ZoneInfo
|
5 |
-
from
|
6 |
import pandas as pd
|
7 |
import json
|
8 |
from pandasql import sqldf
|
9 |
from auth import (get_id_cliente_reciclador)
|
10 |
-
from config import CONFIG
|
11 |
import url64
|
12 |
|
13 |
st.set_page_config(page_title="Lista de recolecciones", page_icon="📆", layout="wide")
|
14 |
-
st.markdown("<style>#MainMenu {visibility: hidden;} footer {visibility: hidden;} /*header {visibility: hidden;}*/</style>", unsafe_allow_html=True)
|
15 |
|
16 |
query_params = st.experimental_get_query_params()
|
17 |
|
@@ -26,8 +24,6 @@ else:
|
|
26 |
# Get user id from token
|
27 |
id_clientereciclador = get_id_cliente_reciclador(raw_token)
|
28 |
|
29 |
-
st.session_state["id_reciclador"] = id_clientereciclador
|
30 |
-
|
31 |
|
32 |
if id_clientereciclador is None:
|
33 |
st.write("🔒 Parece que no tienes permiso para ver esto.")
|
@@ -35,55 +31,10 @@ else:
|
|
35 |
st.title("Lista de Recolección 🚚 📆")
|
36 |
st.markdown('### <span style="color:#9656E2; text-align: center">© Blau tecnología para residuos | blaucorp.com </span>', unsafe_allow_html=True)
|
37 |
|
38 |
-
|
39 |
|
40 |
now = datetime.now(ZoneInfo('America/Mexico_City'))
|
41 |
|
42 |
-
#Preprocesamiento
|
43 |
-
rutas = data["ruta_chofer"].unique()
|
44 |
-
clientes = data["cliente"].unique()
|
45 |
-
sucursal = data["sucursal"].unique()
|
46 |
-
estatus = data["estatus"].unique()
|
47 |
-
|
48 |
-
col1, col2 = st.columns(2)
|
49 |
-
with col1:
|
50 |
-
ruta_filter = st.multiselect("Ruta - Chofer", options=rutas)
|
51 |
-
estatus_filter = st.multiselect("Estatus de servicio", options=estatus)
|
52 |
-
|
53 |
-
with col2:
|
54 |
-
clientes_filter = st.multiselect("Cliente", options=clientes)
|
55 |
-
sucursal_filter = st.multiselect("Sucursal", options=sucursal)
|
56 |
-
|
57 |
-
if len(ruta_filter) == 0:
|
58 |
-
ruta_tupla = tuple(rutas)
|
59 |
-
else:
|
60 |
-
ruta_tupla = tuple(ruta_filter)
|
61 |
-
|
62 |
-
if len(estatus_filter) == 0:
|
63 |
-
estatus_tupla = tuple(estatus)
|
64 |
-
else:
|
65 |
-
estatus_tupla = tuple(estatus_filter)
|
66 |
-
|
67 |
-
if len(sucursal_filter) == 0:
|
68 |
-
sucursal_tupla = tuple(sucursal)
|
69 |
-
else:
|
70 |
-
sucursal_tupla = tuple(sucursal_filter)
|
71 |
-
|
72 |
-
if len(clientes_filter) == 0:
|
73 |
-
clientes_tupla = tuple(clientes)
|
74 |
-
else:
|
75 |
-
clientes_tupla = tuple(clientes_filter)
|
76 |
-
|
77 |
-
format_tuple = lambda t : ", ".join([f"'{v}'" for v in t])
|
78 |
-
q1 = f"""
|
79 |
-
select *
|
80 |
-
from data
|
81 |
-
where ruta_chofer in ({format_tuple(ruta_tupla)}) and cliente in ({format_tuple(clientes_tupla)}) and estatus in ({format_tuple(estatus_tupla)}) and sucursal in ({format_tuple(sucursal_tupla)})
|
82 |
-
"""
|
83 |
-
data_filtered = sqldf(q1)
|
84 |
-
'''
|
85 |
-
|
86 |
-
|
87 |
mode = st.selectbox(
|
88 |
"Modo de calendario:",
|
89 |
(
|
@@ -135,7 +86,6 @@ else:
|
|
135 |
"firstDay": 1
|
136 |
}
|
137 |
|
138 |
-
#data_json = json.loads(data_filtered.to_json(orient='records', date_format='iso'))
|
139 |
data_json = json.loads(data.to_json(orient='records', date_format='iso'))
|
140 |
|
141 |
state = calendar(
|
|
|
2 |
import streamlit as st
|
3 |
from datetime import datetime
|
4 |
from zoneinfo import ZoneInfo
|
5 |
+
from solicitar_data import (get_event)
|
6 |
import pandas as pd
|
7 |
import json
|
8 |
from pandasql import sqldf
|
9 |
from auth import (get_id_cliente_reciclador)
|
|
|
10 |
import url64
|
11 |
|
12 |
st.set_page_config(page_title="Lista de recolecciones", page_icon="📆", layout="wide")
|
|
|
13 |
|
14 |
query_params = st.experimental_get_query_params()
|
15 |
|
|
|
24 |
# Get user id from token
|
25 |
id_clientereciclador = get_id_cliente_reciclador(raw_token)
|
26 |
|
|
|
|
|
27 |
|
28 |
if id_clientereciclador is None:
|
29 |
st.write("🔒 Parece que no tienes permiso para ver esto.")
|
|
|
31 |
st.title("Lista de Recolección 🚚 📆")
|
32 |
st.markdown('### <span style="color:#9656E2; text-align: center">© Blau tecnología para residuos | blaucorp.com </span>', unsafe_allow_html=True)
|
33 |
|
34 |
+
data = get_event(id_clientereciclador)
|
35 |
|
36 |
now = datetime.now(ZoneInfo('America/Mexico_City'))
|
37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
mode = st.selectbox(
|
39 |
"Modo de calendario:",
|
40 |
(
|
|
|
86 |
"firstDay": 1
|
87 |
}
|
88 |
|
|
|
89 |
data_json = json.loads(data.to_json(orient='records', date_format='iso'))
|
90 |
|
91 |
state = calendar(
|