moviewyrm/fedireads/routine_book_tasks.py
Mouse Reeve 9aada80c05 Use timezone dates
Fixes #114
2020-03-29 17:40:51 -07:00

17 lines
531 B
Python

''' Routine tasks for keeping your library tidy '''
from datetime import timedelta
from django.utils import timezone
from fedireads import books_manager
from fedireads import models
def sync_book_data():
''' update books with any changes to their canonical source '''
expiry = timezone.now() - timedelta(days=1)
books = models.Book.objects.filter(
sync=True,
last_sync_date__lte=expiry
).all()
for book in books:
# TODO: create background tasks
books_manager.update_book(book)