See #170: store and compute modification date on artists

This commit is contained in:
Eliot Berriot 2020-03-19 14:41:15 +01:00
commit 1654044a9f
No known key found for this signature in database
GPG key ID: 6B501DFD73514E14
12 changed files with 85 additions and 7 deletions

View file

@ -28,10 +28,17 @@ class ChannelFilter(moderation_filters.HiddenContentFilterSet):
subscribed = django_filters.BooleanFilter(
field_name="_", method="filter_subscribed"
)
ordering = django_filters.OrderingFilter(
# tuple-mapping retains order
fields=(
("creation_date", "creation_date"),
("artist__modification_date", "modification_date"),
)
)
class Meta:
model = models.Channel
fields = ["q", "scope", "tag", "subscribed"]
fields = ["q", "scope", "tag", "subscribed", "ordering"]
hidden_content_fields_mapping = moderation_filters.USER_FILTER_CONFIG["CHANNEL"]
def filter_subscribed(self, queryset, name, value):

View file

@ -384,7 +384,12 @@ def get_channel_from_rss_url(url, raise_exception=False):
library=channel.library,
delete_existing=True,
)
latest_upload_date = max([upload.creation_date for upload in uploads])
if (
not channel.artist.modification_date
or channel.artist.modification_date < latest_upload_date
):
common_utils.update_modification_date(channel.artist)
return channel, uploads