diff --git a/client/src/components/Bookmarks/BookmarkCard/BookmarkCard.module.css b/client/src/components/Bookmarks/BookmarkCard/BookmarkCard.module.css index 4f11ca8..b21ed42 100644 --- a/client/src/components/Bookmarks/BookmarkCard/BookmarkCard.module.css +++ b/client/src/components/Bookmarks/BookmarkCard/BookmarkCard.module.css @@ -28,7 +28,8 @@ .BookmarkIcon { width: 20px; + height: 20px; display: flex; - margin-bottom: 1px; + margin-top: 3px; margin-right: 2px; } \ No newline at end of file diff --git a/utils/clearWeatherData.js b/utils/clearWeatherData.js new file mode 100644 index 0000000..d43f975 --- /dev/null +++ b/utils/clearWeatherData.js @@ -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; \ No newline at end of file diff --git a/utils/jobs.js b/utils/jobs.js index aa8d41c..19dc0a8 100644 --- a/utils/jobs.js +++ b/utils/jobs.js @@ -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(); }) \ No newline at end of file