From ae584f4470f4c5f2ce5e5fd93006494dba18f514 Mon Sep 17 00:00:00 2001 From: forchard Date: Tue, 14 Sep 2021 07:11:58 +0200 Subject: [PATCH] Fix for https://github.com/EU-ECDC/epitweetr/issues/34 on failure when no future slots day are found on task scheduler --- epitweetr/DESCRIPTION | 2 +- epitweetr/R/scheduler.R | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/epitweetr/DESCRIPTION b/epitweetr/DESCRIPTION index f356fc4..9b32760 100644 --- a/epitweetr/DESCRIPTION +++ b/epitweetr/DESCRIPTION @@ -1,6 +1,6 @@ Package: epitweetr Title: Early Detection of Public Health Threats from Twitter Data -Version: 0.1.28 +Version: 0.1.29 Authors@R: c( person(given = "Francisco", family = "Orchard", diff --git a/epitweetr/R/scheduler.R b/epitweetr/R/scheduler.R index 3d86754..19dc94a 100644 --- a/epitweetr/R/scheduler.R +++ b/epitweetr/R/scheduler.R @@ -389,9 +389,9 @@ plan_tasks <-function(statuses = list()) { } else if(tasks[[i]]$end_on >= tasks[[i]]$scheduled_for) { #if the task has ended after the last schedule (which should always be the case) # the last schedule was already executed a new schedule has to be set day_slots <- get_task_day_slots(tasks[[i]]) #Getting all day slots ( times where the detect loop can be executed - next_slot <- day_slots[day_slots > tasks[[i]]$scheduled_for][[1]] #getting the first execution slot after the last scheduled time + next_slots <- day_slots[day_slots > tasks[[i]]$scheduled_for] #getting the future execution slots #if next slot is in future set it. If it is in past, set now - tasks[[i]]$scheduled_for <- if(next_slot > now) next_slot else now + (i - 1)/1000 + tasks[[i]]$scheduled_for <- if(length(next_slots)>0 && next_slots[[1]] > now) next_slots[[1]] else now + (i - 1)/1000 } change <- TRUE break # only first task is set to scheduled