Spaces:
No application file
No application file
Update calendario api
Browse files- calendario api +28 -1
calendario api
CHANGED
|
@@ -120,4 +120,31 @@ json_original = [
|
|
| 120 |
]
|
| 121 |
|
| 122 |
json_adaptado = adaptar_a_formato_oracle(json_original)
|
| 123 |
-
print(json_adaptado)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
]
|
| 121 |
|
| 122 |
json_adaptado = adaptar_a_formato_oracle(json_original)
|
| 123 |
+
print(json_adaptado)
|
| 124 |
+
|
| 125 |
+
|
| 126 |
+
|
| 127 |
+
|
| 128 |
+
from fastapi import FastAPI
|
| 129 |
+
from typing import List
|
| 130 |
+
|
| 131 |
+
app = FastAPI()
|
| 132 |
+
|
| 133 |
+
def adaptar_a_formato_oracle(item):
|
| 134 |
+
nuevo_item = {"resourceId": item["resourceId"], "workSchedules": []}
|
| 135 |
+
|
| 136 |
+
for fecha, status in item.items():
|
| 137 |
+
if fecha != "resourceId":
|
| 138 |
+
record_type = "Descanso Semanal" if status == "Descanso Semanal" else "Ok"
|
| 139 |
+
nuevo_item["workSchedules"].append({
|
| 140 |
+
"recordType": record_type,
|
| 141 |
+
"startDate": fecha,
|
| 142 |
+
"endDate": fecha # Puedes ajustar esto seg煤n tu l贸gica
|
| 143 |
+
})
|
| 144 |
+
|
| 145 |
+
return nuevo_item
|
| 146 |
+
|
| 147 |
+
@app.post("/adaptar_a_oracle")
|
| 148 |
+
async def adaptar_a_oracle(json_original: List[dict]):
|
| 149 |
+
json_adaptado = [adaptar_a_formato_oracle(item) for item in json_original]
|
| 150 |
+
return json_adaptado
|