Merge branch 'traffic_fixes' into 'master'

Traffic fixes

See merge request martind2000/jubilee!3
This commit is contained in:
Martin Donnelly 2018-04-19 20:29:46 +00:00
commit 5459713176
5 changed files with 24 additions and 28 deletions

10
package-lock.json generated
View File

@ -52,7 +52,7 @@
}, },
"@sinonjs/formatio": { "@sinonjs/formatio": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/@sinonjs/formatio/-/formatio-2.0.0.tgz", "resolved": "http://registry.npmjs.org/@sinonjs/formatio/-/formatio-2.0.0.tgz",
"integrity": "sha512-ls6CAMA6/5gG+O/IdsBcblvnd8qcO/l1TYoNeAzp3wcISOxlPXQEus0mLcdwazEkWjaBdaJ3TaxmNgCLWwvWzg==", "integrity": "sha512-ls6CAMA6/5gG+O/IdsBcblvnd8qcO/l1TYoNeAzp3wcISOxlPXQEus0mLcdwazEkWjaBdaJ3TaxmNgCLWwvWzg==",
"dev": true, "dev": true,
"requires": { "requires": {
@ -659,7 +659,7 @@
"resolved": "https://registry.npmjs.org/backbone/-/backbone-1.3.3.tgz", "resolved": "https://registry.npmjs.org/backbone/-/backbone-1.3.3.tgz",
"integrity": "sha1-TMgOp8sWMaxHSInOQPL4vGg7KZk=", "integrity": "sha1-TMgOp8sWMaxHSInOQPL4vGg7KZk=",
"requires": { "requires": {
"underscore": "1.8.3" "underscore": "1.9.0"
} }
}, },
"balanced-match": { "balanced-match": {
@ -11498,9 +11498,9 @@
"dev": true "dev": true
}, },
"underscore": { "underscore": {
"version": "1.8.3", "version": "1.9.0",
"resolved": "https://registry.npmjs.org/underscore/-/underscore-1.8.3.tgz", "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.9.0.tgz",
"integrity": "sha1-Tz+1OxBuYJf8+ctBCfKl6b36UCI=" "integrity": "sha512-4IV1DSSxC1QK48j9ONFK1MoIAKKkbE8i7u55w2R6IqBqbT7A/iG7aZBCR2Bi8piF0Uz+i/MG1aeqLwl/5vqF+A=="
}, },
"union-value": { "union-value": {
"version": "1.0.0", "version": "1.0.0",

View File

@ -49,7 +49,7 @@
"sugar": "^2.0.4", "sugar": "^2.0.4",
"twitter": "^1.7.1", "twitter": "^1.7.1",
"uglifyify": "^4.0.5", "uglifyify": "^4.0.5",
"underscore": "^1.8.3", "underscore": "^1.9.0",
"winston": "^2.4.1", "winston": "^2.4.1",
"winston-mongodb": "^4.0.0-rc1", "winston-mongodb": "^4.0.0-rc1",
"yelp-fusion": "^2.0.3" "yelp-fusion": "^2.0.3"

View File

@ -11,7 +11,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
const CACHE_VERSION = { 'version': '0.0.689' }; const CACHE_VERSION = { 'version': '0.0.695' };
const dataCacheName = 'jubileeData-v1'; const dataCacheName = 'jubileeData-v1';
const cacheName = 'jubilee-final-1'; const cacheName = 'jubilee-final-1';
const filesToCache = [ const filesToCache = [

View File

@ -24,23 +24,20 @@ const TrafficModel = Backbone.Model.extend({
'tick': function() { 'tick': function() {
const hour = (new Date()).getHours(); const hour = (new Date()).getHours();
// ( ((hour >= 7) && (hour <= 9)) || ((hour >= 17) && (hour <= 19)) ) const day = new Date().getDay();
//
console.log('this.has(\'latlong\')', this.has('latlong')); let doRequest = false;
if (this.has('latlong')) { if (day !== 0 && day !== 6)
doRequest = (((hour >= 7) && (hour <= 9)) || ((hour >= 17) && (hour <= 19)));
const delay = doRequest ? 600000 : toHour();
if (this.has('latlong') && doRequest) {
this.updateID = 1; this.updateID = 1;
this.getTraffic(); this.getTraffic();
} }
const day = new Date().getDay();
console.log('tick', this.attributes);
console.log('((hour >= 7) && (hour <= 9))', ((hour >= 7) && (hour <= 9)));
console.log('((hour >= 17) && (hour <= 19))', ((hour >= 17) && (hour <= 19)));
let delay;
if (day === 0 || day === 6)
delay = toHour();
else else
delay = ( ((hour >= 7) && (hour <= 9)) || ((hour >= 17) && (hour <= 19)) ) ? 600000 : toHour(); this.set('mode', 0);
console.log('Delay', delay); console.log('Delay', delay);
this.timerID = setTimeout( this.timerID = setTimeout(
@ -52,7 +49,7 @@ const TrafficModel = Backbone.Model.extend({
this.getTraffic(); this.getTraffic();
}, },
'getTraffic': function() { 'getTraffic': function() {
console.log('Get Raffic'); console.log('Get Traffic');
// olat, olon, dlat, dlon // olat, olon, dlat, dlon
const time = new Date().getTime() ; const time = new Date().getTime() ;
const hour = (new Date()).getHours(); const hour = (new Date()).getHours();
@ -141,8 +138,8 @@ const TrafficView = Backbone.View.extend({
}, },
'template': _.template(` 'template': _.template(`
<div class=""> <div class="">
<div><i class="small fa <%= "fa-" + dest.toLowerCase() %> mui--align-middle "></i> <%=readable%> to <%= dest.toLowerCase() %></div> <div class="itemRow mui--align-middle"><i class=" fa <%= "fa-" + dest.toLowerCase() %> fa-2x mui--align-middle <%= className %>"></i> <%=readable%> to <%= dest.toLowerCase() %> <span class="<%= className %>"><%=traffic %></span></div>
<div class="<%= className %>"><%=traffic %></div>
</div> </div>
`), `),
@ -188,7 +185,6 @@ const parts = new Map(
] ]
); );
module.exports = { TrafficModel, TrafficView }; module.exports = { TrafficModel, TrafficView };

View File

@ -21,7 +21,7 @@ const { NearbyListModel, NearbyListView } = require('./NearbyList');
const { NearbyPlacesView } = require('./NearbyPlaces'); const { NearbyPlacesView } = require('./NearbyPlaces');
var app = app || {}; var app = app || {};
const live = true; const live = false;
if (live) { if (live) {
window.loc = 'https://jubilee.silvrtree.co.uk'; window.loc = 'https://jubilee.silvrtree.co.uk';