mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-07-15 18:07:02 +00:00
jira-290 cron job for expired task
This commit is contained in:
@ -5,6 +5,7 @@ import oss2
|
||||
from django.conf import settings
|
||||
import logging
|
||||
import requests
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
"""Import tempfile"""
|
||||
import tempfile
|
||||
# Import date time module's function
|
||||
@ -13,7 +14,10 @@ from datetime import datetime, time
|
||||
from base.constants import NUMBER, time_url
|
||||
# Import Junior's model
|
||||
from junior.models import Junior, JuniorPoints
|
||||
|
||||
# Import guardian's model
|
||||
from .models import JuniorTask
|
||||
# Import app from celery
|
||||
from zod_bank.celery import app
|
||||
# Define upload image on
|
||||
# ali baba cloud
|
||||
# firstly save image
|
||||
@ -81,3 +85,16 @@ def update_referral_points(referral_code, referral_code_used):
|
||||
junior_query.total_points = junior_query.total_points + NUMBER['five']
|
||||
junior_query.referral_points = junior_query.referral_points + NUMBER['five']
|
||||
junior_query.save()
|
||||
|
||||
|
||||
@app.task
|
||||
def update_expired_task_status(data=None):
|
||||
"""
|
||||
Update task of the status if due date is in past
|
||||
"""
|
||||
try:
|
||||
task_status = [str(NUMBER['one']), str(NUMBER['two'])]
|
||||
JuniorTask.objects.filter(due_date__lt=datetime.today().date(),
|
||||
task_status__in=task_status).update(task_status=str(NUMBER['six']))
|
||||
except ObjectDoesNotExist as e:
|
||||
logging.error(str(e))
|
||||
|
Reference in New Issue
Block a user