from celery import shared_task
from order.models import OrderItemModel, OrderModel
from product.models import DollorModel, ProductVariant

@shared_task
def update_prices():
    # update dollor 
    dollor_object, _ = DollorModel.objects.get_or_create(unique_filed='unique')
    dollor_object.update_price()
    dollor_object.save()
    dollor_price = dollor_object.price
    
    products = list(ProductVariant.objects.all())
    for product in products:
        product.set_or_update_price(dollor_price=dollor_price)
    ProductVariant.objects.bulk_update(products, ['price'], batch_size=1000)