{"id":15673877,"url":"https://github.com/thorwebdev/location-tracer","last_synced_at":"2025-04-16T05:49:11.745Z","repository":{"id":224720577,"uuid":"761597688","full_name":"thorwebdev/location-tRacer","owner":"thorwebdev","description":"#SupaBuilders - Building a Supabase realtime live location sharing app.","archived":false,"fork":false,"pushed_at":"2024-06-11T09:05:22.000Z","size":3818,"stargazers_count":29,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-12-19T10:12:31.859Z","etag":null,"topics":["postgis","postgres","supabase"],"latest_commit_sha":null,"homepage":"https://location-t-racer.vercel.app","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thorwebdev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-22T06:03:22.000Z","updated_at":"2024-12-06T16:47:04.000Z","dependencies_parsed_at":"2024-05-20T05:30:39.386Z","dependency_job_id":"a129a736-0cb0-467f-983b-c56244039a65","html_url":"https://github.com/thorwebdev/location-tRacer","commit_stats":null,"previous_names":["thorwebdev/location-tracer"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thorwebdev%2Flocation-tRacer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thorwebdev%2Flocation-tRacer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thorwebdev%2Flocation-tRacer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thorwebdev%2Flocation-tRacer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thorwebdev","download_url":"https://codeload.github.com/thorwebdev/location-tRacer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230866870,"owners_count":18292300,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["postgis","postgres","supabase"],"created_at":"2024-10-03T15:42:43.446Z","updated_at":"2024-12-22T18:19:44.345Z","avatar_url":"https://github.com/thorwebdev.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"```bash\nsupabase functions serve --no-verify-jwt --env-file .env\nngrok http 53421\nset telegram API webhook: https://api.telegram.org/bot\u003cyour_bot_token\u003e/setWebhook?url=https://\u003cyour_ngrok_domain\u003e.ngrok-free.app/functions/v1/telegram-bot?secret=\u003cyour_function_secret\u003e\n\nsupabase gen types typescript --local --schema=public \u003e supabase/functions/_shared/database.types.ts\n```\n\n## Bot commands\n\nstart - Start tracking an event.\nstop - Stop the currently active event.\nevents - List your events.\nupdate - Update your (team) name.\n\n## Generate types\n\n```bash\n# For supabase functions\nsupabase gen types typescript --linked \u003e supabase/functions/_shared/database.types.ts\n# For nextjs app\nsupabase gen types typescript --linked \u003e app/utils/database.types.ts\n```\n\n## Deploy\n\n```bash\nsupabase link\nsupabase db push\nsupabase functions deploy telegram-bot --no-verify-jwt\nsupabase secrets set --env-file .env\n```\n\n## Useful SQL snippets\n\n### Convert path into WKT\n\n```sql\nselect event_id, user_id, ST_AsText(path) from location_paths;\n```\n\n### Calculate path distance in meters\n\n```sql\nselect event_id, user_id, ST_Length(path::geography) from location_paths;\n```\n\n### Min max timestamp \u0026 duration\n\n- duration is interval data type: https://www.postgresqltutorial.com/postgresql-tutorial/postgresql-interval/\n\n```sql\nwith stats as (\n  SELECT DATE(created_at) as date, event_id, user_id, min(created_at), max(created_at), max(created_at) - min(created_at) as duration\n    FROM locations\n    GROUP BY DATE(created_at), event_id, user_id\n)\nselect date, event_id, user_id,\nEXTRACT(HOUR FROM duration) AS hours,\nEXTRACT(MINUTE FROM duration) AS minutes,\nEXTRACT(SECOND FROM duration) AS seconds,\nEXTRACT(EPOCH FROM duration) AS epoch -- duration in seconds\nfrom stats;\n```\n\n### Calculate average speed\n\n```sql\nwith stats as (\n  SELECT DATE(created_at) as date, event_id, user_id, min(created_at), max(created_at), max(created_at) - min(created_at) as duration, ST_Length(ST_MakeLine(location::geometry ORDER BY created_at)::geography) as distance\n    FROM locations\n    GROUP BY DATE(created_at), event_id, user_id\n)\nselect date, event_id, user_id,\n(distance / EXTRACT(EPOCH FROM duration)) as meters_per_second,\n((distance / EXTRACT(EPOCH FROM duration)) * 3600) / 1000 as kmh\nfrom stats;\n```\n\n## Generate Pmtiles\n\n```bash\n# Singapore Sentosa\n# http://bboxfinder.com/#1.195877,103.788897,1.283919,103.906314\npmtiles extract https://build.protomaps.com/20240320.pmtiles singapore_oc.pmtiles --bbox=103.788897,1.195877,103.906314,1.283919\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthorwebdev%2Flocation-tracer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthorwebdev%2Flocation-tracer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthorwebdev%2Flocation-tracer/lists"}