diff --git a/src/service-worker.js b/src/service-worker.js index 98a191d..979e48d 100644 --- a/src/service-worker.js +++ b/src/service-worker.js @@ -11,7 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -const CACHE_VERSION = { 'version': '0.0.895' }; +const CACHE_VERSION = { 'version': '0.0.906' }; const PRECACHE = `jubileeData-${CACHE_VERSION.version}`; const RUNTIME = 'runtime'; diff --git a/src/v1/js/News.js b/src/v1/js/News.js index b1ffa80..2e28f07 100644 --- a/src/v1/js/News.js +++ b/src/v1/js/News.js @@ -5,6 +5,7 @@ const request = require('request'); const { get } = require('lodash'); const { reduceEuronews } = require('./libs/reducers'); const TimeFormat = require('hh-mm-ss'); +const { hourFloor } = require('./libs/utils'); const NewsItem = Backbone.Model.extend({ @@ -62,7 +63,8 @@ const NewsModel = Backbone.Model.extend({ request({ 'url': `${window.loc}/news`, 'method': 'GET', 'qs': { - 'limit': 10 + 'limit': 10, + 'w' : hourFloor() } }, function(err, res, body) { if (err) diff --git a/src/v1/js/NewsList.js b/src/v1/js/NewsList.js index ff64f64..e1665a9 100644 --- a/src/v1/js/NewsList.js +++ b/src/v1/js/NewsList.js @@ -5,6 +5,7 @@ const request = require('request'); const { get } = require('lodash'); const { reduceEuronews } = require('./libs/reducers'); const { createPanel, addPanel } = require('./libs/panel'); +const { hourFloor } = require('./libs/utils'); const NewsItem = Backbone.Model.extend({ @@ -61,6 +62,7 @@ const NewsListModel = Backbone.Model.extend({ 'url': `${window.loc}/news`, 'method': 'GET', 'qs': { + 'w' : hourFloor() } }, function(err, res, body) { if (err) @@ -122,7 +124,7 @@ const NewsListView = Backbone.View.extend({ }, 'doClick': function(d) { // console.log('Do click', d); - let self = this; + const self = this; const id = get(d, 'currentTarget.dataset.guid', ''); console.log(id); this.eventBus.trigger('showNews', id, () => { diff --git a/src/v1/js/NewsViewer.js b/src/v1/js/NewsViewer.js index 97706de..7af20a0 100644 --- a/src/v1/js/NewsViewer.js +++ b/src/v1/js/NewsViewer.js @@ -4,6 +4,7 @@ const Backbone = require('backbone'); const request = require('request'); const { get, isEmpty } = require('lodash'); const { createPanel, addPanel } = require('./libs/panel'); +const { hourFloor } = require('./libs/utils'); const NewsCardModel = Backbone.Model.extend({ 'initialize': function() { @@ -19,7 +20,8 @@ const NewsCardModel = Backbone.Model.extend({ 'url': `${window.loc}/article`, 'method': 'GET', 'qs': { - 'guid': guid + 'guid': guid, + 'w' : hourFloor() } }, function(err, res, body) { console.log('statusCode', res.statusCode); diff --git a/src/v1/js/Weather.js b/src/v1/js/Weather.js index daa92b4..5351b82 100644 --- a/src/v1/js/Weather.js +++ b/src/v1/js/Weather.js @@ -4,7 +4,7 @@ const Backbone = require('backbone'); const request = require('request'); const { get } = require('lodash'); const { reduceOpenWeather } = require('./libs/reducers'); -const { distance } = require('./libs/utils'); +const { distance, hourFloor } = require('./libs/utils'); const TimeFormat = require('hh-mm-ss'); const weatherItem = Backbone.Model.extend({ @@ -102,7 +102,8 @@ const WeatherModel = Backbone.Model.extend({ 'url': `${window.loc}/weather`, 'method': 'GET', 'qs': { - 'll': llFixed + 'll': llFixed, + 'w' : hourFloor() } }, function(err, res, body) { console.log('statusCode', res.statusCode); diff --git a/src/v1/js/libs/utils.js b/src/v1/js/libs/utils.js index 437cf99..7465899 100644 --- a/src/v1/js/libs/utils.js +++ b/src/v1/js/libs/utils.js @@ -48,6 +48,12 @@ function toHour(extra = 0) { return (3600000 - (now.getTime() % 3600000)) + extra; } +function hourFloor() { + const now = new Date(); + + return (~~(now.getTime() / 3600000) * 3600000); +} + function distance(lat1, lon1, lat2, lon2) { const p = 0.017453292519943295; // Math.PI / 180 const c = Math.cos; @@ -65,5 +71,5 @@ function splitURL(url) { const maybePluralize = (count, noun, suffix = 's') => `${count} ${noun}${count !== 1 ? suffix : ''}`; -module.exports = { partOfDay, toHour, distance, maybePluralize }; +module.exports = { partOfDay, toHour, hourFloor, distance, maybePluralize };