Permalink
Browse files

Attempt to fill in some missing original airdates.

If the guide data provides an original airdate for some showings of a
program but not for others, use the provided one to fill in the other
missing ones.  Based on a patch from Bradley Baetz, but implemented a
little differently.

Fixes #10747
  • Loading branch information...
1 parent 24d4d55 commit d4f6995cf2e4743f452084c8c56bb33c9e6c0372 @gigem gigem committed Oct 9, 2012
Showing with 26 additions and 0 deletions.
  1. +5 −0 mythtv/programs/mythbackend/housekeeper.cpp
  2. +21 −0 mythtv/programs/mythfilldatabase/main.cpp
@@ -673,6 +673,11 @@ void HouseKeeper::CleanupProgramListings(void)
// Keep as many days of listings data as we keep matching, non-recorded
// oldrecorded entries to allow for easier post-mortem analysis
int offset = gCoreContext->GetNumSetting( "CleanOldRecorded", 10);
+ // Also make sure to keep enough data so that we can flag the original
+ // airdate, for when that isn't included in guide data
+ int newEpiWindow = gCoreContext->GetNumSetting( "NewEpisodeWindow", 14);
+ if (newEpiWindow > offset)
+ offset = newEpiWindow;
query.prepare("DELETE FROM oldprogram WHERE airdate < "
"DATE_SUB(CURRENT_DATE, INTERVAL 320 DAY);");
@@ -615,6 +615,27 @@ int main(int argc, char *argv[])
LOG(VB_GENERAL, LOG_INFO, QString(" Found %1").arg(found));
}
+ if (grab_data)
+ {
+ LOG(VB_GENERAL, LOG_INFO, "Fixing missing original airdates.");
+ MSqlQuery query(MSqlQuery::InitCon());
+
+ query.prepare("UPDATE program p "
+ "JOIN ( "
+ " SELECT programid, MAX(originalairdate) maxoad "
+ " FROM program "
+ " WHERE programid <> '' AND "
+ " originalairdate IS NOT NULL "
+ " GROUP BY programid ) oad "
+ " ON p.programid = oad.programid "
+ "SET p.originalairdate = oad.maxoad "
+ "WHERE p.originalairdate IS NULL");
+
+ if (query.exec())
+ LOG(VB_GENERAL, LOG_INFO,
+ QString(" Found %1").arg(query.numRowsAffected()));
+ }
+
if (mark_repeats)
{
LOG(VB_GENERAL, LOG_INFO, "Marking repeats.");

0 comments on commit d4f6995

Please sign in to comment.