Added some tide handling

This commit is contained in:
Martin Donnelly 2020-08-30 16:49:13 +01:00
parent a57fc96bd3
commit 6c3a20078e
5 changed files with 7934 additions and 13 deletions

7882
admiralitySites.json Normal file

File diff suppressed because it is too large Load Diff

View File

@ -14,16 +14,14 @@ const { reduceExplore, reduceYelp, reduceFullFS, reduceTwitter, reducePhotos } =
const twitterClient = new Twitter({
'consumer_key': 'bJvwgjA9O52j7rC6mqoeefPLO',
'consumer_secret': 'NB6ASJxxMI9yaOgTAlWEpd18J1BdtIOYb4iz1HivIVpPqSLBY5',
'access_token_key': '4773651-1IrcQuKzEBQYe89Ooe0wCEP3reiyJZ1SQl003b5DoU',
'access_token_secret': 'AHWGNQLAVGrXeUU3FU1ubdro4z5zc5igeiN4B9qI99xIt'
'access_token_key': '4773651-Ix1Qemdg4k02UV6A4ZRmwgD94eEPmYb6Y77QkzpWZA',
'access_token_secret': 'RweUNv147YCAglOqk8myOVNuoVBvo6F9HPT3kM5ERQtR2'
});
logger.level = 'debug';
// google api key AIzaSyBl7O9LHIthCagcqIaDkQ4um_hghYG5reE
function nowTS() {
const now = new Date();
@ -47,7 +45,7 @@ function doFSVenueSearch(ll, data = {}) {
if (isEmpty(payLoad))
foursquare.venues.search(fsObj, function(err, fsData) {
if (err) {
logger.debug(err);
logger.debug('doFSVenueSearch', err);
return reject(err);
}
@ -137,7 +135,7 @@ function doYelpSearch(data = {}) {
return resolve(payLoad);
}).catch(e => {
console.error(e);
console.error('doYelpSearch', e);
return reject(e);
});
@ -225,8 +223,11 @@ function doTweetSearch(data = {}) {
const params = { 'screen_name': payLoad.twitter };
twitterClient.get('statuses/user_timeline', params, function(error, tweets, response) {
if (error)
if (error) {
console.error('doTweetSearch', error);
return reject(error);
}
else {
// const partPayload = reduceFullFS(get(fsData, 'response.venue'));
// const newPayload = Object.assign(payLoad, partPayload);
@ -324,7 +325,7 @@ function doGetMoreDetail(id) {
// res.status(500).send('There was an error!');
})
.then((d) => {
logger.info('Final', d.name, d.id);
logger.info('Final', (d.name || '***** Name Missing'), d.id);
jsonfile.writeFileSync(`output/${d.id}-doGetMoreDetail.json`, d);
return resolve(d);

View File

@ -22,7 +22,7 @@ function doGetFourSquareExplore(ll, limit = 3, section = 'topPicks', query = '')
console.log('>> fsObj', fsObj);
foursquare.venues.explore(fsObj, function(err, fsData) {
logger.debug(err);
logger.error(err);
if (err)
return reject(err);
else

38
server/tides.js Normal file
View File

@ -0,0 +1,38 @@
/**
* Created by WebStorm.
* User: martin
* Date: 07/07/2020
* Time: 16:40
Look here https://admiraltyapi.portal.azure-api.net/docs/services/uk-tidal-api/operations/TidalEvents_GetTidalEvents?
it's an api
reduce admiralitySites.json to something better for quick searching against lat long.
helensburgh 0403
Primary key
b49297c9dacc4c6e92026d0dbec82948
Secondary key
d51efd816c2446b29e8be0f019c06f9c
https://admiraltyapi.azure-api.net/uktidalapi/api/V1/Stations/{stationId}/TidalEvents[?duration]
HTTP request
============
GET https://admiraltyapi.azure-api.net/uktidalapi/api/V1/Stations/0403/TidalEvents?duration=3 HTTP/1.1
Host: admiraltyapi.azure-api.net
Ocp-Apim-Subscription-Key: b49297c9dacc4c6e92026d0dbec82948
*/

View File

@ -56,16 +56,16 @@ const templates = {
</div>
</div>
`),
'venueTitle' : _.template(`
'venueTitle': _.template(`
<div class="mui--text-display1 mui--text-center" style="font-weight: 900;"><%=name %></div>
`),
'venueDescription' : _.template(`
'venueDescription': _.template(`
<div class="mui--text-body1" ><%=description %></div>
`),
'venueDirections' : _.template(`
'venueDirections': _.template(`
<div class="mui--text-subhead mui--text-center separate" style="" id="getDirections"><p><i class="fa fa-sm fa-map-marker mui--align-middle " ></i><%=address%></p><p>Directions</p></div>
`),
'openInFS' : _.template(`
'openInFS': _.template(`
<div style="margin-bottom:50px"><a href="<%=url%>">Open in Foursquare</a></div>
`),
'map': _.template('<div id="map"></div>'),