[UPDT] BASE: Updated scheduler add_job function call by adding it in a condition to start
This commit is contained in:
@@ -4,6 +4,7 @@ scheduler.py
|
||||
This module is used to register scheduled tasks
|
||||
"""
|
||||
|
||||
import sys
|
||||
from datetime import date, timedelta
|
||||
|
||||
from apscheduler.schedulers.background import BackgroundScheduler
|
||||
@@ -83,7 +84,11 @@ def notify_expiring_documents():
|
||||
document.is_active = False
|
||||
|
||||
|
||||
scheduler = BackgroundScheduler()
|
||||
scheduler.add_job(notify_expiring_assets, "interval", hours=4)
|
||||
scheduler.add_job(notify_expiring_documents, "interval", hours=4)
|
||||
scheduler.start()
|
||||
if not any(
|
||||
cmd in sys.argv
|
||||
for cmd in ["makemigrations", "migrate", "compilemessages", "flush", "shell"]
|
||||
):
|
||||
scheduler = BackgroundScheduler()
|
||||
scheduler.add_job(notify_expiring_assets, "interval", hours=4)
|
||||
scheduler.add_job(notify_expiring_documents, "interval", hours=4)
|
||||
scheduler.start()
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import calendar
|
||||
import datetime as dt
|
||||
import sys
|
||||
from datetime import date, datetime, timedelta
|
||||
|
||||
from apscheduler.schedulers.background import BackgroundScheduler
|
||||
@@ -429,66 +430,67 @@ def recurring_holiday():
|
||||
recurring_holiday.save()
|
||||
|
||||
|
||||
scheduler = BackgroundScheduler()
|
||||
if not any(
|
||||
cmd in sys.argv
|
||||
for cmd in ["makemigrations", "migrate", "compilemessages", "flush", "shell"]
|
||||
):
|
||||
scheduler = BackgroundScheduler()
|
||||
|
||||
# Set the initial start time to the current time
|
||||
start_time = datetime.now()
|
||||
# Add jobs with next_run_time set to the end of the previous job
|
||||
try:
|
||||
scheduler.add_job(rotate_shift, "interval", minutes=5, id="job1")
|
||||
except:
|
||||
pass
|
||||
|
||||
# Add jobs with next_run_time set to the end of the previous job
|
||||
try:
|
||||
scheduler.add_job(rotate_shift, "interval", minutes=5, id="job1")
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
scheduler.add_job(
|
||||
rotate_work_type,
|
||||
"interval",
|
||||
minutes=5,
|
||||
id="job2",
|
||||
)
|
||||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
scheduler.add_job(
|
||||
rotate_work_type,
|
||||
"interval",
|
||||
minutes=5,
|
||||
id="job2",
|
||||
)
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
scheduler.add_job(
|
||||
undo_shift,
|
||||
"interval",
|
||||
minutes=5,
|
||||
id="job3",
|
||||
)
|
||||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
scheduler.add_job(
|
||||
undo_shift,
|
||||
"interval",
|
||||
minutes=5,
|
||||
id="job3",
|
||||
)
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
scheduler.add_job(
|
||||
switch_shift,
|
||||
"interval",
|
||||
minutes=5,
|
||||
id="job4",
|
||||
)
|
||||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
scheduler.add_job(
|
||||
switch_shift,
|
||||
"interval",
|
||||
minutes=5,
|
||||
id="job4",
|
||||
)
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
scheduler.add_job(
|
||||
undo_work_type,
|
||||
"interval",
|
||||
minutes=5,
|
||||
id="job6",
|
||||
)
|
||||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
scheduler.add_job(
|
||||
undo_work_type,
|
||||
"interval",
|
||||
minutes=5,
|
||||
id="job6",
|
||||
)
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
scheduler.add_job(
|
||||
switch_work_type,
|
||||
"interval",
|
||||
minutes=5,
|
||||
id="job5",
|
||||
)
|
||||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
scheduler.add_job(
|
||||
switch_work_type,
|
||||
"interval",
|
||||
minutes=5,
|
||||
id="job5",
|
||||
)
|
||||
except:
|
||||
pass
|
||||
|
||||
scheduler.add_job(recurring_holiday, "interval", hours=4)
|
||||
scheduler.start()
|
||||
scheduler.add_job(recurring_holiday, "interval", hours=4)
|
||||
scheduler.start()
|
||||
|
||||
@@ -133,7 +133,8 @@ def block_unblock_disciplinary():
|
||||
|
||||
|
||||
if not any(
|
||||
cmd in sys.argv for cmd in ["makemigrations", "migrate", "compilemessages", "flush"]
|
||||
cmd in sys.argv
|
||||
for cmd in ["makemigrations", "migrate", "compilemessages", "flush", "shell"]
|
||||
):
|
||||
"""
|
||||
Initializes and starts background tasks using APScheduler when the server is running.
|
||||
|
||||
@@ -48,7 +48,8 @@ def leave_reset():
|
||||
|
||||
|
||||
if not any(
|
||||
cmd in sys.argv for cmd in ["makemigrations", "migrate", "compilemessages", "flush"]
|
||||
cmd in sys.argv
|
||||
for cmd in ["makemigrations", "migrate", "compilemessages", "flush", "shell"]
|
||||
):
|
||||
"""
|
||||
Initializes and starts background tasks using APScheduler when the server is running.
|
||||
|
||||
@@ -171,7 +171,7 @@
|
||||
</div>
|
||||
<div class="col-sm-12 col-md-12">
|
||||
<div class="oh-input-group oh-label__info">
|
||||
<label for="id_carryforward_expire_date" class="oh-label">{% trans "Carryforward Expire In" %}</label>
|
||||
<label for="id_carryforward_expire_date" class="oh-label">{% trans "Carryforward Expire Date" %}</label>
|
||||
<span class=" oh-info me-3" title="{% trans 'The date on which carryforward leave resets to 0. After this reset, the date will be updated to the next expiration period.' %}"></span>
|
||||
</div>
|
||||
{{form.carryforward_expire_date}}
|
||||
|
||||
@@ -5,6 +5,7 @@ This module is used to register scheduled tasks
|
||||
"""
|
||||
|
||||
import json
|
||||
import sys
|
||||
from datetime import date, timedelta
|
||||
|
||||
from apscheduler.schedulers.background import BackgroundScheduler
|
||||
@@ -137,7 +138,11 @@ def auto_payslip_generate():
|
||||
generate_payslip(date=date.today(), companies=companies, all=False)
|
||||
|
||||
|
||||
scheduler = BackgroundScheduler()
|
||||
scheduler.add_job(expire_contract, "interval", hours=4)
|
||||
scheduler.add_job(auto_payslip_generate, "interval", hours=3)
|
||||
scheduler.start()
|
||||
if not any(
|
||||
cmd in sys.argv
|
||||
for cmd in ["makemigrations", "migrate", "compilemessages", "flush", "shell"]
|
||||
):
|
||||
scheduler = BackgroundScheduler()
|
||||
scheduler.add_job(expire_contract, "interval", hours=4)
|
||||
scheduler.add_job(auto_payslip_generate, "interval", hours=3)
|
||||
scheduler.start()
|
||||
|
||||
@@ -48,7 +48,8 @@ def candidate_convert():
|
||||
|
||||
|
||||
if not any(
|
||||
cmd in sys.argv for cmd in ["makemigrations", "migrate", "compilemessages", "flush"]
|
||||
cmd in sys.argv
|
||||
for cmd in ["makemigrations", "migrate", "compilemessages", "flush", "shell"]
|
||||
):
|
||||
"""
|
||||
Initializes and starts background tasks using APScheduler when the server is running.
|
||||
|
||||
Reference in New Issue
Block a user