Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete IPTV channel data when the channel is removed #986

Merged
merged 1 commit into from
Dec 7, 2024
Merged
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
16 changes: 16 additions & 0 deletions mythtv/programs/mythbackend/backendhousekeeper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@ void CleanupTask::CleanupChannelTables(void)
MSqlQuery query(MSqlQuery::InitCon());
MSqlQuery deleteQuery(MSqlQuery::InitCon());

// Delete all channels from the database that have already
// been deleted for at least one day and that are not referenced
// anymore by a recording.
query.prepare(QString("DELETE channel "
"FROM channel "
"LEFT JOIN recorded r "
Expand All @@ -219,6 +222,8 @@ void CleanupTask::CleanupChannelTables(void)
MythDB::DBError("CleanupTask::CleanupChannelTables "
"(channel table)", query);

// Delete all multiplexes from the database that are not
// referenced anymore by a channel.
query.prepare(QString("DELETE dtv_multiplex "
"FROM dtv_multiplex "
"LEFT JOIN channel c "
Expand All @@ -227,6 +232,17 @@ void CleanupTask::CleanupChannelTables(void)
if (!query.exec())
MythDB::DBError("CleanupTask::CleanupChannelTables "
"(dtv_multiplex table)", query);

// Delete all IPTV channel data extension records from the database
// when the channel it refers to does not exist anymore.
query.prepare(QString("DELETE iptv_channel "
"FROM iptv_channel "
"LEFT JOIN channel c "
" ON c.chanid = iptv_channel.chanid "
"WHERE c.chanid IS NULL"));
if (!query.exec())
MythDB::DBError("CleanupTask::CleanupChannelTables "
"(iptv_channel table)", query);
}

void CleanupTask::CleanupProgramListings(void)
Expand Down
Loading