YunoHost-Apps / aeneria_ynh

æneria package for YunoHost
GNU Affero General Public License v3.0
11 stars 2 forks source link

Slow down the cron #12

Closed PetitMote closed 2 years ago

PetitMote commented 3 years ago

Currently, the cron try to fetch data every 20 minutes. Enedis doesn't publish the data before about 9:30 am. For 0:00 to 9:30, there is an error and an error mail every 20 minutes.

The data doesn't need to be fetched every 20 minutes. I propose to change the cron, so it's called every 1 or 2 hours, instead.

SimonMellerin commented 3 years ago

You certainly right about the cron interval but can you give me the error you have in your mails ?

It should not mail you each time this command is trigger, it may be a normal behavior to not have data, the system should not mail you for this.

SimonMellerin commented 3 years ago

Any news on this ?

Jaxom99 commented 2 years ago

if I may add, here is the plead to "API good practices" by Enedis (just read them today): Une livraison toutes les 2h Les données Linky arrivent au fil de l’eau, toutes les 2h, à partir de 6h du matin. Il n’est pas utile de demander les données plus fréquemment ou à l’intérieur d’une même fenêtre de 2h

Une fois par jour Les données sont collectées une fois par jour par les compteurs communicants. Il n’est donc pas nécessaire d’appeler plusieurs fois les mêmes données dans la même journée : elles n’auront pas changé.

Thanks for keeping this project up Simon :+1:

SimonMellerin commented 2 years ago

Hi,

I understand your concern but what you have to see is that the cron job does not try to fetch data from Enedis each time it's launched.

The job will first check in database if a feed needs to be updated and then try to fetch new data but only if the feed is out to date.

Each type of feed (MeteoFrance or Enedis feed and soon Grdf) has in own logic to check if a feed is up to date: data from MeteoFrance Synop data are available at midnight while data from Enedis are available at 6am.

So basically, most of the time, the cron will perform may be 1 or 2 SQL Select queries and that's it.

This behavior (launching a job every 20min to check if data are up to date for each feed) was first introduced cause at the beginning of aeneria, Enedis API was not really reliable. It was often unavailable. This mechanism allows aeneria to be more robust keeping data the most up to date possible.