from datetime import timedelta
from django.utils import timezone

from accounts.models import Customers


# Assuming your Customers model is imported and defined correctly

def get_recently_updated_customers(company):
    current_datetime = timezone.now()
    two_years_ago = current_datetime - timedelta(days=2 * 365)
    recently_updated_customers = Customers.objects.filter(batch__created_by__company=company, updated__gte=two_years_ago).exclude(password='').order_by('-updated')[:5]

    return recently_updated_customers
