[RMV] ATTENDANCE: Remove __init__.py and scheduler.py

This commit is contained in:
Horilla
2024-08-16 10:21:33 +05:30
parent 432e17ca9b
commit 46a569db8d
2 changed files with 0 additions and 51 deletions

View File

@@ -1 +0,0 @@
from attendance import scheduler

View File

@@ -1,50 +0,0 @@
import datetime
from datetime import datetime
from apscheduler.schedulers.background import BackgroundScheduler
from django.utils import timezone as django_timezone
def auto_check_out():
from attendance.models import AttendanceActivity
from attendance.views.clock_in_out import clock_out_attendance_and_activity
from base.models import EmployeeShiftSchedule
from employee.models import Employee
try:
today = django_timezone.make_aware(datetime.now())
shift_schedules = EmployeeShiftSchedule.objects.all()
employees = Employee.objects.all()
for employee in employees:
work_info = getattr(employee, "employee_work_info", None)
shift_id = getattr(work_info, "shift_id", None)
shift_schedule = shift_schedules.filter(
day__day=today.strftime("%A").lower(), shift_id=shift_id
).first()
attendance_activity = AttendanceActivity.objects.filter(
employee_id=employee, clock_out__isnull=True
).first()
if (
shift_schedule
and attendance_activity
and attendance_activity.attendance_date < today.date()
):
if (
not attendance_activity.clock_out
and shift_schedule.start_time <= today.time()
):
attendance = clock_out_attendance_and_activity(
employee=employee,
date_today=today.date(),
now=today.time().strftime("%H:%M"),
out_datetime=today,
)
except:
pass
scheduler = BackgroundScheduler()
scheduler.add_job(auto_check_out, "interval", seconds=30)
scheduler.start()