Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
[this.channelFilter]: true,
page: this.$route.query.page || 1,
exclude: this.currentChannelId,
ordering: this.channelFilter === 'public' ? 'name' : '-modified',
}).then(page => {
this.pageCount = page.total_pages;
this.channels = page.results;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

import { mapGetters, mapActions } from 'vuex';
import orderBy from 'lodash/orderBy';
import { RouteNames, CHANNEL_PAGE_SIZE } from '../../constants';
import { RouteNames } from '../../constants';
import ChannelItem from './ChannelItem';
import LoadingText from 'shared/views/LoadingText';
import { ChannelListTypes } from 'shared/constants';
Expand Down Expand Up @@ -98,9 +98,6 @@
isEditable() {
return this.listType === ChannelListTypes.EDITABLE;
},
isStarred() {
return this.listType === ChannelListTypes.STARRED;
},
},
watch: {
listType(newListType) {
Expand Down Expand Up @@ -129,17 +126,6 @@
},
loadData(listType) {
this.loading = true;
let parameters = {
listType,
sortBy: '-modified',
};

// Don't paginate bookmarked channel list for more
// rapid updating when channels are starred/unstarred
if (!this.isStarred) {
parameters.page = Number(this.$route.query.page || 1);
parameters.page_size = CHANNEL_PAGE_SIZE;
}

this.loadChannelList({ listType }).then(() => {
this.loading = false;
Expand Down
20 changes: 14 additions & 6 deletions contentcuration/contentcuration/viewsets/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,8 @@ class ChannelViewSet(ValuesViewset):
serializer_class = ChannelSerializer
pagination_class = ChannelListPagination
filterset_class = ChannelFilter
ordering_fields = ["modified", "name"]
ordering = "-modified"

field_map = channel_field_map
values = base_channel_values + ("edit", "view", "unpublished_changes")
Expand All @@ -412,6 +414,15 @@ def get_queryset(self):
queryset = super(ChannelViewSet, self).get_queryset()
user_id = not self.request.user.is_anonymous and self.request.user.id
user_queryset = User.objects.filter(id=user_id)
# Add the last modified node modified value as the channel last modified
channel_main_tree_nodes = ContentNode.objects.filter(
tree_id=OuterRef("main_tree__tree_id")
)
queryset = queryset.annotate(
modified=Subquery(
channel_main_tree_nodes.values("modified").order_by("-modified")[:1]
)
)

return queryset.annotate(
edit=Exists(user_queryset.filter(editable_channels=OuterRef("id"))),
Expand All @@ -423,12 +434,7 @@ def annotate_queryset(self, queryset):
channel_main_tree_nodes = ContentNode.objects.filter(
tree_id=OuterRef("main_tree__tree_id")
)
# Add the last modified node modified value as the channel last modified
queryset = queryset.annotate(
modified=Subquery(
channel_main_tree_nodes.values("modified").order_by("-modified")[:1]
)
)

# Add the unique count of distinct non-topic node content_ids
non_topic_content_ids = (
channel_main_tree_nodes.exclude(kind_id=content_kinds.TOPIC)
Expand Down Expand Up @@ -561,6 +567,8 @@ class CatalogViewSet(ReadOnlyValuesViewset):
serializer_class = ChannelSerializer
pagination_class = CatalogListPagination
filterset_class = BaseChannelFilter
ordering_fields = []
ordering = ("-priority", "name")

permission_classes = [AllowAny]

Expand Down