Clear weather data job. Fixed bug with displaying bookmark icons on mobile devices
This commit is contained in:
parent
80c807bfba
commit
936da301b8
3 changed files with 27 additions and 3 deletions
|
@ -28,7 +28,8 @@
|
|||
|
||||
.BookmarkIcon {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
display: flex;
|
||||
margin-bottom: 1px;
|
||||
margin-top: 3px;
|
||||
margin-right: 2px;
|
||||
}
|
22
utils/clearWeatherData.js
Normal file
22
utils/clearWeatherData.js
Normal file
|
@ -0,0 +1,22 @@
|
|||
const { Op } = require('sequelize');
|
||||
const Weather = require('../models/Weather');
|
||||
|
||||
const clearWeatherData = async () => {
|
||||
const weather = await Weather.findOne({
|
||||
order: [[ 'createdAt', 'DESC' ]]
|
||||
});
|
||||
|
||||
if (weather) {
|
||||
await Weather.destroy({
|
||||
where: {
|
||||
id: {
|
||||
[Op.lt]: weather.id
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
console.log('Old weather data was deleted');
|
||||
}
|
||||
|
||||
module.exports = clearWeatherData;
|
|
@ -1,5 +1,6 @@
|
|||
const schedule = require('node-schedule');
|
||||
const getExternalWeather = require('./getExternalWeather');
|
||||
const clearWeatherData = require('./clearWeatherData');
|
||||
const Sockets = require('../Sockets');
|
||||
|
||||
// Update weather data every 15 minutes
|
||||
|
@ -14,6 +15,6 @@ const weatherJob = schedule.scheduleJob('updateWeather', '0 */15 * * * *', async
|
|||
})
|
||||
|
||||
// Clear old weather data every 4 hours
|
||||
const weatherCleanerJob = schedule.scheduleJob('clearWeather', '0 0 */4 * * *', async () => {
|
||||
console.log('clean')
|
||||
const weatherCleanerJob = schedule.scheduleJob('clearWeather', '0 5 */4 * * *', async () => {
|
||||
clearWeatherData();
|
||||
})
|
Loading…
Add table
Reference in a new issue