Observe: Incorrect number of failed Resources on Home/start page.
Reason/cause: the function get_last_runs()
The intended use is to get the last Run for each Resource.
Before per-Resource scheduling, all Resources were always Run each hour.
So this was simply the last N records from the Run table, where N is the number of Resource records.
Now this is no longer true after the per-Resource scheduling PR: if Resource A is scheduled every 5 mins and Resource B every 4 hours, then the last N Records of the Run table will certainly not contain Runs of Resource B! This explains the sometimes incorrect listings of failed resources on the Home page!
So the current function does return the last N records but not the last Run for each Resource (anymore)! :
def get_last_runs(count):
"""return last N Runs"""
last_id = DB.session.query(func.max(Run.identifier)).first()[0]
if not last_id:
return []
rsc_count = get_resources_count()
return DB.session.query(Run).filter(
Run.identifier > (last_id - rsc_count)).limit(count).all()
We see that first the last id is fetched and then the last_id -N records.
Observe: Incorrect number of failed Resources on Home/start page.
Reason/cause: the function get_last_runs()
The intended use is to get the last Run for each Resource.
Before per-Resource scheduling, all Resources were always Run each hour.
So this was simply the last N records from the Run table, where N is the number of Resource records.
Now this is no longer true after the per-Resource scheduling PR: if Resource A is scheduled every 5 mins and Resource B every 4 hours, then the last N Records of the Run table will certainly not contain Runs of Resource B! This explains the sometimes incorrect listings of failed resources on the Home page!
So the current function does return the last N records but not the last Run for each Resource (anymore)! :
We see that first the last id is fetched and then the last_id -N records.