diff --git a/osinaweb/celerybeat-schedule.db b/osinaweb/celerybeat-schedule.db index 1be98d6f..d8b202fb 100644 Binary files a/osinaweb/celerybeat-schedule.db and b/osinaweb/celerybeat-schedule.db differ diff --git a/osinaweb/db.sqlite3 b/osinaweb/db.sqlite3 index c349ed87..2ffb026a 100644 Binary files a/osinaweb/db.sqlite3 and b/osinaweb/db.sqlite3 differ diff --git a/osinaweb/osinacore/__pycache__/tasks.cpython-310.pyc b/osinaweb/osinacore/__pycache__/tasks.cpython-310.pyc index 368ddb16..2e724132 100644 Binary files a/osinaweb/osinacore/__pycache__/tasks.cpython-310.pyc and b/osinaweb/osinacore/__pycache__/tasks.cpython-310.pyc differ diff --git a/osinaweb/osinacore/tasks.py b/osinaweb/osinacore/tasks.py index 394abb66..3d0892cd 100644 --- a/osinaweb/osinacore/tasks.py +++ b/osinaweb/osinacore/tasks.py @@ -6,25 +6,24 @@ from django.db.models import Q @shared_task def set_offline(): all_staff_profiles = StaffProfile.objects.all() - for staff_profile in all_staff_profiles: last_working_point_activity = PointActivity.objects.filter( point__status='Working On', - point__task__assigned_to=staff_profile, - ).order_by('-end_time').first() - - if last_working_point_activity and last_working_point_activity.end_time <= datetime.now() - timedelta(minutes=10): - user = staff_profile.user - last_connection = Connection.objects.filter(user=user).order_by('-date').first() - if last_connection is None or last_connection.status != 'Offline': - Connection.objects.create( - status='Offline', - date=datetime.now(), - user=user - ) - Status.objects.create( - text='I am now offline!', - date=datetime.now().date(), - time=datetime.now().strftime('%I:%M %p'), - staff=user.staffprofile - ) \ No newline at end of file + point__task__assigned_to=staff_profile + ).last() + if last_working_point_activity and last_working_point_activity.end_time: + if last_working_point_activity.end_time <= datetime.now() - timedelta(minutes=10): + user = staff_profile.user + last_connection = Connection.objects.filter(user=user).order_by('-date').first() + if last_connection.status != 'Offline': + Connection.objects.create( + status='Offline', + date=datetime.now(), + user=user + ) + Status.objects.create( + text='I am now offline!', + date=datetime.now().date(), + time=datetime.now().strftime('%I:%M %p'), + staff=staff_profile + ) \ No newline at end of file diff --git a/osinaweb/osinaweb/__pycache__/celery.cpython-310.pyc b/osinaweb/osinaweb/__pycache__/celery.cpython-310.pyc index e551eedb..2fdff8c3 100644 Binary files a/osinaweb/osinaweb/__pycache__/celery.cpython-310.pyc and b/osinaweb/osinaweb/__pycache__/celery.cpython-310.pyc differ