|
@@ -5,7 +5,7 @@ import random
|
|
|
import time
|
|
|
|
|
|
from hvs import scheduler
|
|
|
-from hvs.app import download_resources, need_refill, refill, save_resources, print_resources
|
|
|
+from hvs.app import download_resources, need_refill, max_refill_seconds, refill, save_resources, print_resources
|
|
|
|
|
|
|
|
|
def job_check_resources(state_id, capital_id, resource_id):
|
|
@@ -13,8 +13,9 @@ def job_check_resources(state_id, capital_id, resource_id):
|
|
|
regions = download_resources(state_id, resource_id)
|
|
|
save_resources(state_id, regions, resource_id)
|
|
|
print_resources(regions)
|
|
|
- if need_refill(regions):
|
|
|
- random_time = timedelta(seconds=random.randint(0, 300))
|
|
|
+ if need_refill(regions, 25):
|
|
|
+ max_seconds = max_refill_seconds(regions, 25, 900)
|
|
|
+ random_time = timedelta(seconds=random.randint(0, max_seconds))
|
|
|
scheduled_date = datetime.now() + random_time
|
|
|
job_id = 'refill_{}_{}'.format(capital_id, resource_id)
|
|
|
print('refill resource: {} at {} ({} minutes)'.format(
|