import { createLocation, getLocationByQuery, getLocationByRadius, } from "../models/Location/operations"; /* Sample Location Payload { "extras": {}, "activity": { "confidence": 100, "type": "still" }, "timestamp": "2026-04-25T17:31:25.320Z", "battery": { "level": 0.57, "is_charging": false }, "recorded_at": "2026-04-25T17:31:25.388Z", "age": 0.074, "is_moving": false, "event": "motionchange", "uuid": "4c476d94-b7db-4823-9270-805235ed0ec8", "coords": { "ellipsoidal_altitude": 0, "altitude": 0, "altitude_accuracy": 0.5, "heading_accuracy": -1, "heading": -1, "speed": 0, "accuracy": 5, "longitude": 77.48675, "speed_accuracy": 0.5, "latitude": 9.9707883 }, "odometer_error": 0, "odometer": 0 } */ export const createLocationController = async (req, res) => { try { const { user } = res.locals; const { location } = req.body; const dbPayload = { battery: location.battery.level, coordinates: location.coords, event: location.event, heading: location.coords.heading, activity: location?.activity?.type, recorded_at: location.recorded_at, }; const uploaded = await createLocation({ ...dbPayload, user: user?.id }); console.log("BG LOCATION DB DOC", uploaded, user); res.status(200).json({ result: uploaded }); } catch (error) { console.log("createLocationController Error", error); res.status(500).json({ error: error.message }); } }; export const getLocationController = async (req, res) => { try { const location = await getLocationByQuery(req.query); res.status(200).json(location); } catch (error) { res.status(500).json({ error: error.message }); } };