mirror of
https://gitlab.silvrtree.co.uk/martind2000/old-silvrgit.git
synced 2025-01-25 19:26:18 +00:00
cron for today to send emails
This commit is contained in:
parent
878323eba8
commit
f7e17b02de
6
.idea/encodings.xml
Normal file
6
.idea/encodings.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Encoding">
|
||||||
|
<file url="PROJECT" charset="UTF-8" />
|
||||||
|
</component>
|
||||||
|
</project>
|
8
.idea/modules.xml
Normal file
8
.idea/modules.xml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/silvrgit.iml" filepath="$PROJECT_DIR$/.idea/silvrgit.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
8
.idea/silvrgit.iml
Normal file
8
.idea/silvrgit.iml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="WEB_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<content url="file://$MODULE_DIR$" />
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -22,9 +22,9 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Ends',
|
title: 'Ends',
|
||||||
y: 2015,
|
y: 2016,
|
||||||
m: 4,
|
m: 4,
|
||||||
d: 10
|
d: 4
|
||||||
}];
|
}];
|
||||||
var addDays = function (myDate, days) {
|
var addDays = function (myDate, days) {
|
||||||
return new Date(myDate.getTime() + days * 24 * 60 * 60 * 1000);
|
return new Date(myDate.getTime() + days * 24 * 60 * 60 * 1000);
|
||||||
@ -45,7 +45,7 @@
|
|||||||
var third = new Date();
|
var third = new Date();
|
||||||
start101.setFullYear(2013, 9, 24);
|
start101.setFullYear(2013, 9, 24);
|
||||||
end101 = addDays(start101, 1001);
|
end101 = addDays(start101, 1001);
|
||||||
endContract.setFullYear(2015, 4, 10);
|
endContract.setFullYear(2016, 4, 4);
|
||||||
third.setFullYear(2013, 7, 25);
|
third.setFullYear(2013, 7, 25);
|
||||||
$('#one').text('101B ends: ' + Math.ceil(getDays(today,
|
$('#one').text('101B ends: ' + Math.ceil(getDays(today,
|
||||||
end101)) + " days / " + Math.ceil(getDays(today,
|
end101)) + " days / " + Math.ceil(getDays(today,
|
||||||
|
28
lib/jade/today.jade
Normal file
28
lib/jade/today.jade
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
doctype html
|
||||||
|
html(lang="en")
|
||||||
|
head
|
||||||
|
title= Today
|
||||||
|
|
||||||
|
body
|
||||||
|
h1 Today
|
||||||
|
#container.weather
|
||||||
|
h2 Weather
|
||||||
|
p Currently:
|
||||||
|
= ' ' + data.weather.currently
|
||||||
|
p Later:
|
||||||
|
= ' ' + data.weather.today
|
||||||
|
|
||||||
|
if data.weather.alerts.length > 0
|
||||||
|
h3 ALERT
|
||||||
|
each alert in data.weather.alerts
|
||||||
|
p(style="color:red;")= alert.title
|
||||||
|
p= alert.description
|
||||||
|
|
||||||
|
#container.weather
|
||||||
|
if data.trains.data.length > 0
|
||||||
|
h2 Trains
|
||||||
|
each alert in data.trains.data
|
||||||
|
strong= alert.title
|
||||||
|
p= alert.description
|
||||||
|
|
||||||
|
|
@ -34,27 +34,21 @@ var left = ["Alabama",
|
|||||||
"Nevada",
|
"Nevada",
|
||||||
"New Hampshire",
|
"New Hampshire",
|
||||||
"New Jersey",
|
"New Jersey",
|
||||||
"New Mexico",
|
"Mexico",
|
||||||
"New York",
|
"New York",
|
||||||
"North Carolina",
|
"Carolina",
|
||||||
"North Dakota",
|
"Dakota",
|
||||||
"Ohio",
|
"Ohio",
|
||||||
"Oklahoma",
|
"Oklahoma",
|
||||||
"Oregon",
|
"Oregon",
|
||||||
"Palau",
|
"Palau",
|
||||||
"Pennsylvania",
|
"Pennsylvania",
|
||||||
"Puerto Rico",
|
|
||||||
"Rhode Island",
|
|
||||||
"South Carolina",
|
|
||||||
"South Dakota",
|
|
||||||
"Tennessee",
|
"Tennessee",
|
||||||
"Texas",
|
"Texas",
|
||||||
"Utah",
|
"Utah",
|
||||||
"Vermont",
|
"Vermont",
|
||||||
"Virgin Islands",
|
|
||||||
"Virginia",
|
"Virginia",
|
||||||
"Washington",
|
"Washington",
|
||||||
"West Virginia",
|
|
||||||
"Wisconsin",
|
"Wisconsin",
|
||||||
"Wyoming",
|
"Wyoming",
|
||||||
"Glasgow",
|
"Glasgow",
|
||||||
|
57
lib/today.js
57
lib/today.js
@ -1,7 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
* Created by marti on 30/01/2016.
|
* Created by marti on 30/01/2016.
|
||||||
*/
|
*/
|
||||||
var http = require('http'), request = require('request'), cheerio = require('cheerio'), Forecast = require('forecast.io'), util = require('util');
|
var http = require('http'), request = require('request'), cheerio = require('cheerio'), Forecast = require('forecast.io'), util = require('util'),UltraSES = require('ultrases'),cron = require('node-cron');
|
||||||
|
var jade = require('jade'), _ = require('lodash');
|
||||||
|
|
||||||
var todayCache = {
|
var todayCache = {
|
||||||
last: 0,
|
last: 0,
|
||||||
@ -23,6 +24,27 @@ var forecastOptions = {
|
|||||||
units: 'uk2'
|
units: 'uk2'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var mailer = new UltraSES({
|
||||||
|
aws: {
|
||||||
|
accessKeyId: 'AKIAJWJS75F7WNCGK64A',
|
||||||
|
secretAccessKey: '8irYxThCp4xxyrbr00HzWcODe2qdNrR7X7S5BKup',
|
||||||
|
"region": "eu-west-1"
|
||||||
|
},
|
||||||
|
defaults: {
|
||||||
|
from: 'Martin Donnelly <martind2000@gmail.com>'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Array.prototype.indexOfOld=Array.prototype.indexOf
|
||||||
|
|
||||||
|
Array.prototype.indexOf=function(e,fn){
|
||||||
|
if(!fn){return this.indexOfOld(e)}
|
||||||
|
else{
|
||||||
|
if(typeof fn ==='string'){var att=fn;fn=function(e){return e[att];}}
|
||||||
|
return this.map(fn).indexOfOld(e);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
getToday: function (req, res) {
|
getToday: function (req, res) {
|
||||||
res.render('pages/today', todayCache);
|
res.render('pages/today', todayCache);
|
||||||
@ -70,15 +92,16 @@ module.exports = {
|
|||||||
// join arrays
|
// join arrays
|
||||||
|
|
||||||
for (var i = 0; i < outputArray.length; i++) {
|
for (var i = 0; i < outputArray.length; i++) {
|
||||||
|
var p = todayCache.data.trains.data.indexOf(outputArray[i].title);
|
||||||
|
console.log('P: ' + p);
|
||||||
todayCache.data.trains.data.push(outputArray[i])
|
todayCache.data.trains.data.push(outputArray[i])
|
||||||
}
|
}
|
||||||
|
todayCache.data.trains.data = _.uniq(todayCache.data.trains.data);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
todayCache.data.trains.last = now;
|
todayCache.data.trains.last = now;
|
||||||
|
|
||||||
// todayCache.data.trains.data = j;
|
|
||||||
|
|
||||||
},
|
},
|
||||||
updateTrains: function () {
|
updateTrains: function () {
|
||||||
console.log('Updating trains..');
|
console.log('Updating trains..');
|
||||||
@ -131,8 +154,36 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
function sendEmail() {
|
||||||
|
var email = {
|
||||||
|
to: 'martind2000@gmail.com',
|
||||||
|
subject: 'Today'
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
var template = { file: 'jade/today.jade', locals: todayCache };
|
||||||
|
mailer.sendTemplate(email, template, function(err){
|
||||||
|
if(err) throw err;
|
||||||
|
console.log('compiled template email sent');
|
||||||
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
|
var fn = jade.compileFile(template.file);
|
||||||
|
|
||||||
|
console.log(fn(todayCache));
|
||||||
|
*/
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
// console.log('Pre loading trains...');
|
// console.log('Pre loading trains...');
|
||||||
module.exports.preLoadToday();
|
module.exports.preLoadToday();
|
||||||
|
|
||||||
}, 15000);
|
}, 15000);
|
||||||
|
|
||||||
|
cron.schedule('1 00 7 * * *', function(){
|
||||||
|
sendEmail();
|
||||||
|
// console.log('tick');
|
||||||
|
return -1;
|
||||||
|
});
|
@ -6,6 +6,8 @@
|
|||||||
"ejs": "^2.3.4",
|
"ejs": "^2.3.4",
|
||||||
"forecast.io": "0.0.9",
|
"forecast.io": "0.0.9",
|
||||||
"htmlparser": "^1.7.7",
|
"htmlparser": "^1.7.7",
|
||||||
|
"jade": "^1.11.0",
|
||||||
|
"jsonfile": "^2.2.3",
|
||||||
"mammoth": "^0.3.25-pre.1",
|
"mammoth": "^0.3.25-pre.1",
|
||||||
"request": "^2.67.0",
|
"request": "^2.67.0",
|
||||||
"simple-weather": "^1.2.2",
|
"simple-weather": "^1.2.2",
|
||||||
@ -13,7 +15,10 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"express": "3.x",
|
"express": "3.x",
|
||||||
|
"lodash": "^4.3.0",
|
||||||
|
"node-cron": "^1.0.0",
|
||||||
"scrape": "^0.2.3",
|
"scrape": "^0.2.3",
|
||||||
|
"ultrases": "^0.1.3",
|
||||||
"unstyler": "^0.2.2"
|
"unstyler": "^0.2.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -169,8 +169,9 @@
|
|||||||
|
|
||||||
<div class="mui-row">
|
<div class="mui-row">
|
||||||
<div class="mui-col-md-4">
|
<div class="mui-col-md-4">
|
||||||
<div class="mui-text-title mui-text-black">Job Searching</div>
|
<div class="mui-text-title mui-text-black">Contracting</div>
|
||||||
<ul>
|
<ul>
|
||||||
|
<li><a href='https://outsauce.backofficeportal.com/Secure/Candidate/Default.aspx'>Outsauce Timesheets</a></li>
|
||||||
<li><a href='https://worksheets.computerfutures.com/'>CF Timesheets</a></li>
|
<li><a href='https://worksheets.computerfutures.com/'>CF Timesheets</a></li>
|
||||||
<li><a href="http://www.monster.co.uk/">monster</a></li>
|
<li><a href="http://www.monster.co.uk/">monster</a></li>
|
||||||
<li><a href="http://www.cwjobs.co.uk/">cwjobs</a></li>
|
<li><a href="http://www.cwjobs.co.uk/">cwjobs</a></li>
|
||||||
|
Loading…
Reference in New Issue
Block a user