Skip to content

Commit

Permalink
added timezone column to maps-scraper
Browse files Browse the repository at this point in the history
  • Loading branch information
AV committed Jul 9, 2023
1 parent 6c85360 commit 190fea9
Show file tree
Hide file tree
Showing 4 changed files with 238 additions and 13 deletions.
215 changes: 215 additions & 0 deletions superscraper/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 9 additions & 3 deletions superscraper/scrapers/maps/maps-scraper.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// This script reads location data from the Overland app (https://github.com/aaronpk/Overland-iOS) and from my scraper app, and saves it to the database.

const express = require('express');
const app = express();
const db = require('../_utils/db.js');
const geoTz = require('geo-tz');

const schema = 'maps';
const tableName = 'raw_visited_places';
Expand Down Expand Up @@ -43,7 +42,7 @@ async function handleRootEndpoint(req, res) {
}

async function handleMapsEndpoint(req, res) {
console.log(JSON.stringify(req.body, null, 2));
// console.log(JSON.stringify(req.body, null, 2));
const locations = req.body.location;

/*
Expand All @@ -63,12 +62,19 @@ async function handleMapsEndpoint(req, res) {
const data = [];
locations.forEach((location) => {
const coordinates = `POINT(${location.coords.longitude} ${location.coords.latitude})`;
let tz = geoTz.find(location.coords.latitude, location.coords.longitude)[0] || ''; // Get local timezone with geo-tz

data.push([
{
name: 'time',
value: location.timestamp,
type: 'TIMESTAMP WITH TIME ZONE',
},
{
name: 'timezone',
value: tz,
type: 'TEXT',
},
{
name: 'coordinates',
value: coordinates,
Expand Down
Loading

0 comments on commit 190fea9

Please sign in to comment.