Spaces:
Sleeping
Sleeping
Bell Operations Copilot — batch upload
Browse files77 unmodified lines78798081828347 unmodified lines13113213313413513665 unmodified lines20220320420520620777 unmodified linesself.menu = load_menu_from_file()self.orders: list[dict] = []self.call_logs: dict[str, dict] = {}def get_menu(self) -> list[dict]:return self.menu47 unmodified linesself.call_logs[key] = existingreturn existingdef health(self) -> dict:return {"store": "memory", "menu_items": len(self.menu), "orders": len(self.orders)}65 unmodified lines)return res.data[0] if res.data else logdef health(self) -> dict:count = (self.client.table("menu_items").select("id", count="exact").execute().count77 unmodified lines7879808182838447 unmodified lines13213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318465 unmodified lines25025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830977 unmodified linesself.menu = load_menu_from_file()self.orders: list[dict] = []self.call_logs: dict[str, dict] = {}self.reservations: list[dict] = []def get_menu(self) -> list[dict]:return self.menu47 unmodified linesself.call_logs[key] = existingreturn existingdef list_call_logs(self, limit: int = 50) -> list[dict]:rows = sorted(self.call_logs.values(), key=lambda r: r.get("created_at", ""), reverse=True)return rows[:limit]def latest_call_log(self, table_number: str, outlet_location: str) -> Optional[dict]:from datetime import datetime, timezone, timedeltacutoff = (datetime.now(timezone.utc) - timedelta(minutes=10)).isoformat()for row in self.list_call_logs(100):if (str(row.get("table_number")) == str(table_number)and (row.get("outlet_location") or "").lower() == outlet_location.lower()and row.get("created_at", "") >= cutoff):return rowreturn Nonedef insert_reservation(self, reservation: dict) -> dict:reservation = {**reservation,"id": str(uuid.uuid4()),"status": "pending","created_at": _now(),}self.reservations.append(reservation)return reservationdef list_reservations(self, status: Optional[str] = None) -> list[dict]:rows = self.reservationsif status:rows = [r for r in rows if r.get("status") == status]return sorted(rows, key=lambda r: r.get("created_at", ""), reverse=True)def update_reservation_status(self, reservation_id: str, status: str) -> Optional[dict]:for r in self.reservations:if r["id"] == reservation_id:r["status"] = statusreturn rreturn Nonedef update_menu_availability(self, item_name: str, is_available: bool) -> bool:name_lower = item_name.strip().lower()for item in self.menu:if item["name"].lower() == name_lower:item["is_available"] = is_availablereturn Truereturn Falsedef health(self) -> dict:return {"store": "memory", "menu_items": len(self.menu), "orders": len(self.orders)}65 unmodified lines)return res.data[0] if res.data else logdef list_call_logs(self, limit: int = 50) -> list[dict]:res = (self.client.table("call_logs").select("*").order("created_at", desc=True).limit(limit).execute())return res.data or []def latest_call_log(self, table_number: str, outlet_location: str) -> Optional[dict]:from datetime import datetime, timezone, timedeltacutoff = (datetime.now(timezone.utc) - timedelta(minutes=10)).isoformat()res = (self.client.table("call_logs").select("*").eq("table_number", str(table_number)).ilike("outlet_location", outlet_location).gte("created_at", cutoff).order("created_at", desc=True).limit(1).execute())return res.data[0] if res.data else Nonedef insert_reservation(self, reservation: dict) -> dict:res = self.client.table("reservations").insert(reservation).execute()return res.data[0]def list_reservations(self, status: Optional[str] = None) -> list[dict]:q = self.client.table("reservations").select("*").order("created_at", desc=True).limit(100)if status:q = q.eq("status", status)return q.execute().data or []def update_reservation_status(self, reservation_id: str, status: str) -> Optional[dict]:res = (self.client.table("reservations").update({"status": status}).eq("id", reservation_id).execute())return res.data[0] if res.data else Nonedef update_menu_availability(self, item_name: str, is_available: bool) -> bool:res = (self.client.table("menu_items").update({"is_available": is_available}).ilike("name", item_name).execute())self._menu_cache = [] # bust the cachereturn bool(res.data)def health(self) -> dict:count = (self.client.table("menu_items").select("id", count="exact").execute().count
store.py+102