cybertron-spark 0.1.6__tar.gz → 0.1.8__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {cybertron_spark-0.1.6 → cybertron_spark-0.1.8}/PKG-INFO +1 -1
- {cybertron_spark-0.1.6 → cybertron_spark-0.1.8}/cybertron_spark/heartbeat.py +62 -1
- {cybertron_spark-0.1.6 → cybertron_spark-0.1.8}/cybertron_spark.egg-info/PKG-INFO +1 -1
- {cybertron_spark-0.1.6 → cybertron_spark-0.1.8}/setup.py +1 -1
- {cybertron_spark-0.1.6 → cybertron_spark-0.1.8}/LICENCE +0 -0
- {cybertron_spark-0.1.6 → cybertron_spark-0.1.8}/README.md +0 -0
- {cybertron_spark-0.1.6 → cybertron_spark-0.1.8}/cybertron_spark/__init__.py +0 -0
- {cybertron_spark-0.1.6 → cybertron_spark-0.1.8}/cybertron_spark/selenium.py +0 -0
- {cybertron_spark-0.1.6 → cybertron_spark-0.1.8}/cybertron_spark/zenpy.py +0 -0
- {cybertron_spark-0.1.6 → cybertron_spark-0.1.8}/cybertron_spark.egg-info/SOURCES.txt +0 -0
- {cybertron_spark-0.1.6 → cybertron_spark-0.1.8}/cybertron_spark.egg-info/dependency_links.txt +0 -0
- {cybertron_spark-0.1.6 → cybertron_spark-0.1.8}/cybertron_spark.egg-info/requires.txt +0 -0
- {cybertron_spark-0.1.6 → cybertron_spark-0.1.8}/cybertron_spark.egg-info/top_level.txt +0 -0
- {cybertron_spark-0.1.6 → cybertron_spark-0.1.8}/setup.cfg +0 -0
|
@@ -4,6 +4,8 @@ import requests
|
|
|
4
4
|
import traceback
|
|
5
5
|
import urllib3
|
|
6
6
|
from dotenv import load_dotenv
|
|
7
|
+
import pandas as pd
|
|
8
|
+
import numpy as np
|
|
7
9
|
|
|
8
10
|
# Desabilita avisos de certificados inseguros (opcional, conforme seu código original)
|
|
9
11
|
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
|
@@ -113,6 +115,33 @@ class Heartbeat():
|
|
|
113
115
|
|
|
114
116
|
return self._post(endpoint, payload)
|
|
115
117
|
|
|
118
|
+
def registrar_lote(self, lista_ou_df):
|
|
119
|
+
endpoint = '/transformers/bots-tickets/'
|
|
120
|
+
payload_lote = []
|
|
121
|
+
|
|
122
|
+
if hasattr(lista_ou_df, 'to_dict'):
|
|
123
|
+
dados_raw = lista_ou_df.to_dict(orient='records')
|
|
124
|
+
|
|
125
|
+
elif isinstance(lista_ou_df, list):
|
|
126
|
+
dados_raw = lista_ou_df
|
|
127
|
+
else:
|
|
128
|
+
print("❌ Erro: registrar_lote espera uma Lista ou DataFrame.")
|
|
129
|
+
return None
|
|
130
|
+
|
|
131
|
+
for item in dados_raw:
|
|
132
|
+
registro = {
|
|
133
|
+
'bot_id': self.bot_id,
|
|
134
|
+
'ticket_id': str(item.get('ticket_id') or item.get('service_protocol') or item.get('pedido') or item.get('order_code') or ''),
|
|
135
|
+
'pedido': str(item.get('pedido') or item.get('order_code') or ''),
|
|
136
|
+
'protocolo': str(item.get('protocolo') or item.get('service_protocol') or ''),
|
|
137
|
+
'output_data': item
|
|
138
|
+
}
|
|
139
|
+
payload_lote.append(registro)
|
|
140
|
+
|
|
141
|
+
if payload_lote:
|
|
142
|
+
print(f"📤 Enviando lote de {len(payload_lote)} tickets...")
|
|
143
|
+
return self._post(endpoint, payload_lote)
|
|
144
|
+
|
|
116
145
|
def atualizar_fila(self, quantidade):
|
|
117
146
|
endpoint = '/transformers/bots-queue/'
|
|
118
147
|
|
|
@@ -175,4 +204,36 @@ class Heartbeat():
|
|
|
175
204
|
'bot_realizado': True,
|
|
176
205
|
}
|
|
177
206
|
|
|
178
|
-
return self._patch(endpoint, payload)
|
|
207
|
+
return self._patch(endpoint, payload)
|
|
208
|
+
|
|
209
|
+
def salvar_bugiganga(self, dataframe):
|
|
210
|
+
endpoint = '/transformers/bots-bugigangasave/'
|
|
211
|
+
|
|
212
|
+
df_save = dataframe.copy()
|
|
213
|
+
colunas_data = ['abertura', 'dt_status', 'dt_cancelamento', 'ult_msg', 'dt_entrega', 'dt_prevista', 'created_at']
|
|
214
|
+
|
|
215
|
+
for col in colunas_data:
|
|
216
|
+
if col in df_save.columns:
|
|
217
|
+
df_save[col] = pd.to_datetime(df_save[col], errors='coerce').dt.strftime('%Y-%m-%dT%H:%M:%S')
|
|
218
|
+
|
|
219
|
+
df_save = df_save.replace({np.nan: None})
|
|
220
|
+
df_save = df_save.where(pd.notnull(df_save), None)
|
|
221
|
+
|
|
222
|
+
payload_total = df_save.to_dict(orient='records')
|
|
223
|
+
|
|
224
|
+
batch_size = 500
|
|
225
|
+
total_enviado = 0
|
|
226
|
+
|
|
227
|
+
print(f"📦 Iniciando envio de {len(payload_total)} registros para o banco...")
|
|
228
|
+
|
|
229
|
+
for i in range(0, len(payload_total), batch_size):
|
|
230
|
+
lote = payload_total[i:i + batch_size]
|
|
231
|
+
|
|
232
|
+
response = self._post(endpoint, lote)
|
|
233
|
+
if response and response.status_code in [200, 201]:
|
|
234
|
+
total_enviado += len(lote)
|
|
235
|
+
else:
|
|
236
|
+
print(f"⚠️ Falha no lote {i} a {i+batch_size}")
|
|
237
|
+
|
|
238
|
+
print(f"🏁 Finalizado. Total salvo no banco: {total_enviado}")
|
|
239
|
+
return total_enviado
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{cybertron_spark-0.1.6 → cybertron_spark-0.1.8}/cybertron_spark.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|