[enh] store a random day for job on repo

This commit is contained in:
Laurent Peuch 2018-09-08 08:28:00 +02:00
parent 480bda0e9a
commit c408f30ef2
2 changed files with 7 additions and 0 deletions

View file

@ -14,6 +14,8 @@ class Repo(peewee.Model):
('other_than_working', 'Other than working'), ('other_than_working', 'Other than working'),
), default="other_than_working") ), default="other_than_working")
random_job_day = peewee.IntegerFieldIntegerField(null=True)
class Meta: class Meta:
database = db database = db

5
run.py
View file

@ -179,6 +179,10 @@ async def monitor_apps_lists(type="stable"):
repo.state = repo_state repo.state = repo_state
repo.save() repo.save()
if repo.random_job_day is None:
repo.random_job_day = randint(1, 28)
repo.save()
# new app # new app
else: else:
task_logger.info(f"New application detected: {app_id} in {app_list_name}, scheduling a new job") task_logger.info(f"New application detected: {app_id} in {app_list_name}, scheduling a new job")
@ -188,6 +192,7 @@ async def monitor_apps_lists(type="stable"):
revision=commit_sha, revision=commit_sha,
app_list=app_list_name, app_list=app_list_name,
state="working" if app_data["state"] in ("working", "validated") else "other_than_working", state="working" if app_data["state"] in ("working", "validated") else "other_than_working",
random_job_day=randint(1, 28),
) )
await create_job(app_id, app_list_name, repo, job_command_last_part) await create_job(app_id, app_list_name, repo, job_command_last_part)