chore: remove unsued sql view, resolves #158

This commit is contained in:
FrenchGithubUser
2025-12-15 23:35:35 +01:00
parent 96a38889e2
commit f29a5687d2

View File

@@ -1001,89 +1001,6 @@ SELECT
ORDER BY
t.id;
CREATE VIEW get_title_groups_and_edition_group_and_torrents_lite AS
WITH edition_groups_with_torrents AS (
SELECT
eg.id AS eg_id,
eg.title_group_id,
jsonb_build_object(
'id', eg.id,
'title_group_id', eg.title_group_id,
'name', eg.name,
'release_date', eg.release_date,
'distributor', eg.distributor,
'covers', eg.covers,
'source', eg.source,
'additional_information', eg.additional_information,
'torrents', COALESCE(jsonb_agg(
jsonb_build_object(
'id', tar.id, 'upload_factor', tar.upload_factor, 'download_factor', tar.download_factor,
'seeders', tar.seeders, 'leechers', tar.leechers, 'times_completed', tar.times_completed,
'edition_group_id', tar.edition_group_id, 'created_at', tar.created_at, 'extras', tar.extras,
'release_name', tar.release_name, 'release_group', tar.release_group,
'file_amount_per_type', tar.file_amount_per_type, 'trumpable', tar.trumpable,
'staff_checked', tar.staff_checked, 'languages', tar.languages,
'container', tar.container, 'size', tar.size, 'duration', tar.duration,
'audio_codec', tar.audio_codec, 'audio_bitrate', tar.audio_bitrate,
'audio_bitrate_sampling', tar.audio_bitrate_sampling, 'audio_channels', tar.audio_channels,
'video_codec', tar.video_codec, 'features', tar.features,
'subtitle_languages', tar.subtitle_languages, 'video_resolution', tar.video_resolution,
'video_resolution_other_x', tar.video_resolution_other_x, 'video_resolution_other_y', tar.video_resolution_other_y,
'reports', tar.reports
) ORDER BY tar.id
) FILTER (WHERE tar.id IS NOT NULL), '[]'::jsonb)
) AS eg_data,
MIN(tar.created_at) AS min_torrent_created_at,
MAX(tar.created_at) AS max_torrent_created_at,
MIN(tar.size) AS min_torrent_size,
MAX(tar.size) AS max_torrent_size
FROM
edition_groups eg
LEFT JOIN torrents_and_reports tar ON eg.id = tar.edition_group_id
GROUP BY
eg.id
),
affiliated_artists_data AS (
SELECT
aa.title_group_id,
jsonb_agg(
jsonb_build_object(
'id', ar.id,
'name', ar.name
) ORDER BY ar.name
) AS affiliated_artists
FROM
affiliated_artists aa
JOIN artists ar ON aa.artist_id = ar.id
GROUP BY
aa.title_group_id
)
SELECT
tgr.id AS title_group_id,
jsonb_build_object(
'id', tgr.id,
'name', tgr.name,
'covers', tgr.covers,
'category', tgr.category,
'content_type', tgr.content_type,
-- 'tags', tgr.tags,
'original_release_date', tgr.original_release_date,
'platform', tgr.platform
) || jsonb_build_object(
'edition_groups', COALESCE(jsonb_agg(egwt.eg_data ORDER BY egwt.eg_id) FILTER (WHERE egwt.eg_data IS NOT NULL), '[]'::jsonb),
'affiliated_artists', COALESCE(aad.affiliated_artists, '[]'::jsonb)
) AS title_group_data
FROM
title_groups tgr
LEFT JOIN edition_groups_with_torrents egwt ON tgr.id = egwt.title_group_id
LEFT JOIN affiliated_artists_data aad ON tgr.id = aad.title_group_id
GROUP BY
tgr.id, tgr.name, tgr.covers, tgr.category, tgr.content_type, tgr.original_release_date, tgr.platform, aad.affiliated_artists
ORDER BY
tgr.original_release_date DESC,
tgr.id ASC;
CREATE MATERIALIZED VIEW title_group_hierarchy_lite AS
SELECT
title_groups.id AS title_group_id,