2020-03-28 23:30:54 +00:00
|
|
|
''' Routine tasks for keeping your library tidy '''
|
2020-03-30 00:40:51 +00:00
|
|
|
from datetime import timedelta
|
|
|
|
from django.utils import timezone
|
2020-09-21 15:10:37 +00:00
|
|
|
from bookwyrm import books_manager
|
|
|
|
from bookwyrm import models
|
2020-03-28 23:30:54 +00:00
|
|
|
|
|
|
|
def sync_book_data():
|
|
|
|
''' update books with any changes to their canonical source '''
|
2020-03-30 00:40:51 +00:00
|
|
|
expiry = timezone.now() - timedelta(days=1)
|
2020-04-02 02:38:07 +00:00
|
|
|
books = models.Edition.objects.filter(
|
2020-03-28 23:30:54 +00:00
|
|
|
sync=True,
|
|
|
|
last_sync_date__lte=expiry
|
|
|
|
).all()
|
|
|
|
for book in books:
|
|
|
|
# TODO: create background tasks
|
|
|
|
books_manager.update_book(book)
|