Remove now unneeded ChannelAgg endpoint

And update frontend to format per new endpoint
This commit is contained in:
Caleb Rogers 2026-06-17 15:35:09 +02:00
parent 3836b2bf45
commit 3b2b8a46d0
4 changed files with 5 additions and 65 deletions

View File

@ -99,21 +99,6 @@ class ChannelUpdateSerializer(serializers.Serializer):
channel_overwrites = ChannelOverwriteSerializer(required=False)
class ChannelAggBucketSerializer(serializers.Serializer):
"""serialize channel agg bucket"""
value = serializers.IntegerField()
value_str = serializers.CharField(required=False)
class ChannelAggSerializer(serializers.Serializer):
"""serialize channel aggregation"""
total_items = ChannelAggBucketSerializer()
total_size = ChannelAggBucketSerializer()
total_duration = ChannelAggBucketSerializer()
class ChannelNavSerializer(serializers.Serializer):
"""serialize channel navigation"""

View File

@ -19,11 +19,6 @@ urlpatterns = [
views.ChannelApiView.as_view(),
name="api-channel",
),
path(
"<slug:channel_id>/aggs/",
views.ChannelAggsApiView.as_view(),
name="api-channel-aggs",
),
path(
"<slug:channel_id>/nav/",
views.ChannelNavApiView.as_view(),

View File

@ -1,7 +1,6 @@
"""all channel API views"""
from channel.serializers import (
ChannelAggSerializer,
ChannelListQuerySerializer,
ChannelListSerializer,
ChannelNavSerializer,
@ -189,38 +188,6 @@ class ChannelApiView(ApiBaseView):
return Response(error.data, status=404)
class ChannelAggsApiView(ApiBaseView):
"""resolves to /api/channel/<channel_id>/aggs/
GET: get channel aggregations
"""
search_base = "ta_video/_search"
@extend_schema(
responses={
200: OpenApiResponse(ChannelAggSerializer()),
},
)
def get(self, request, channel_id):
"""get channel aggregations"""
self.data.update(
{
"query": {
"term": {"channel.channel_id": {"value": channel_id}}
},
"aggs": {
"total_items": {"value_count": {"field": "youtube_id"}},
"total_size": {"sum": {"field": "media_size"}},
"total_duration": {"sum": {"field": "player.duration"}},
},
}
)
self.get_aggs()
serializer = ChannelAggSerializer(self.response)
return Response(serializer.data)
class ChannelNavApiView(ApiBaseView):
"""resolves to /api/channel/<channel_id>/nav/
GET: get channel nav

View File

@ -22,8 +22,8 @@ import loadVideoListByFilter, {
WatchTypes,
WatchTypesEnum,
} from '../api/loader/loadVideoListByPage';
import loadChannelAggs, { ChannelAggsType } from '../api/loader/loadChannelAggs';
import humanFileSize from '../functions/humanFileSize';
import formatTime from '../functions/formatTime';
import { useUserConfigStore } from '../stores/UserConfigStore';
import { FileSizeUnits } from '../api/actions/updateUserConfig';
import { ApiResponseType } from '../functions/APIClient';
@ -51,16 +51,12 @@ const ChannelVideo = ({ videoType }: ChannelVideoProps) => {
const [channelResponse, setChannelResponse] = useState<ApiResponseType<ChannelResponseType>>();
const [videoResponse, setVideoReponse] =
useState<ApiResponseType<VideoListByFilterResponseType>>();
const [videoAggsResponse, setVideoAggsResponse] = useState<ApiResponseType<ChannelAggsType>>();
const { data: channelResponseData } = channelResponse ?? {};
const { data: videoResponseData } = videoResponse ?? {};
const { data: videoAggsResponseData } = videoAggsResponse ?? {};
const channel = channelResponseData;
const videoList = videoResponseData?.data;
const pagination = videoResponseData?.paginate;
const videoAggs = videoAggsResponseData;
const hasVideos = videoResponseData?.data?.length !== 0;
const useSiUnits = userConfig.file_size_unit === FileSizeUnits.Metric;
@ -87,11 +83,8 @@ const ChannelVideo = ({ videoType }: ChannelVideoProps) => {
type: videoType,
height: filterHeight,
});
const channelAggs = await loadChannelAggs(channelId);
setChannelResponse(channelResponse);
setVideoReponse(videos);
setVideoAggsResponse(channelAggs);
setRefresh(false);
})();
}, [
@ -123,13 +116,13 @@ const ChannelVideo = ({ videoType }: ChannelVideoProps) => {
setRefresh={setRefresh}
/>
<div className="info-box-item">
{videoAggs && (
{channel.channel_video_count !== undefined && (
<>
<p>
{videoAggs.total_items.value} videos <span className="space-carrot">|</span>{' '}
{videoAggs.total_duration.value_str} playback{' '}
{channel.channel_video_count} videos <span className="space-carrot">|</span>{' '}
{formatTime(channel.channel_media_duration ?? 0)} playback{' '}
<span className="space-carrot">|</span> Total size{' '}
{humanFileSize(videoAggs.total_size.value, useSiUnits)}
{humanFileSize(channel.channel_media_size ?? 0, useSiUnits)}
</p>
<div className="button-box">
<Button