1
0
Fork 0

Periodically update books

Fixes #21
This commit is contained in:
Mouse Reeve 2020-03-28 16:30:54 -07:00
parent 0c9aad730d
commit 06ff795df1
5 changed files with 42 additions and 14 deletions

View file

@ -0,0 +1,16 @@
''' Routine tasks for keeping your library tidy '''
from datetime import datetime, timedelta
from fedireads import books_manager
from fedireads import models
def sync_book_data():
''' update books with any changes to their canonical source '''
expiry = datetime.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)