Ticket #2544: mythtv-cleanup_recording_rules_and_oldrecorded_in_housekeeper.patch

File mythtv-cleanup_recording_rules_and_oldrecorded_in_housekeeper.patch, 4.7 KB (added by sphery <mtdean@…>, 15 years ago)
  • programs/mythbackend/housekeeper.h

     
    3535    void CleanupMyOldRecordings(void);
    3636    void CleanupAllOldInUsePrograms(void);
    3737    void CleanupRecordedTables(void);
     38    void CleanupExpiredRecordingRules(void);
     39    void CleanupOldrecordedTable(void);
    3840    bool threadrunning;
    3941    bool filldbRunning;
    4042    bool isMaster;
  • programs/mythbackend/housekeeper.cpp

     
    225225                JobQueue::CleanupOldJobsInQueue();
    226226                CleanupAllOldInUsePrograms();
    227227                CleanupRecordedTables();
     228                CleanupExpiredRecordingRules();
     229                CleanupOldrecordedTable();
    228230                updateLastrun("DailyCleanup");
    229231            }
    230232        }
     
    368370    }
    369371}
    370372
     373void HouseKeeper::CleanupExpiredRecordingRules(void)
     374{
     375    MSqlQuery query(MSqlQuery::InitCon());
     376    MSqlQuery findq(MSqlQuery::InitCon());
     377
     378    query.prepare("DELETE FROM record WHERE (type = :SINGLE "
     379                  "OR type = :OVERRIDE OR type = :DONTRECORD) "
     380                  "AND enddate < NOW();");
     381    query.bindValue(":SINGLE", kSingleRecord);
     382    query.bindValue(":OVERRIDE", kOverrideRecord);
     383    query.bindValue(":DONTRECORD", kDontRecord);
     384    query.exec();
     385
     386    findq.prepare("SELECT record.recordid FROM record "
     387                  "LEFT JOIN oldfind ON oldfind.recordid = record.recordid "
     388                  "WHERE type = :FINDONE AND oldfind.findid IS NOT NULL;");
     389    findq.bindValue(":FINDONE", kFindOneRecord);
     390    findq.exec();
     391
     392    if (findq.isActive() && findq.size() > 0)
     393    {
     394        while (findq.next())
     395        {
     396            query.prepare("DELETE FROM record WHERE recordid = :RECORDID;");
     397            query.bindValue(":RECORDID", findq.value(0).toInt());
     398            query.exec();
     399        }
     400    }
     401
     402    query.prepare("DELETE FROM oldfind WHERE findid < TO_DAYS(NOW()) - 14;");
     403    query.exec();
     404}
     405
     406void HouseKeeper::CleanupOldrecordedTable(void)
     407{
     408    MSqlQuery query(MSqlQuery::InitCon());
     409    int cleanOldRecorded = gContext->GetNumSetting( "CleanOldRecorded", 10);
     410
     411    query.prepare("DELETE FROM oldrecorded WHERE "
     412                  "recstatus <> :RECORDED AND duplicate = 0 AND "
     413                  "endtime < DATE_SUB(CURRENT_DATE, INTERVAL :CLEAN DAY);");
     414    query.bindValue(":RECORDED", rsRecorded);
     415    query.bindValue(":CLEAN", cleanOldRecorded);
     416    query.exec();
     417}
     418
    371419void *HouseKeeper::doHouseKeepingThread(void *param)
    372420{
    373421    HouseKeeper *hkeeper = (HouseKeeper*)param;
  • programs/mythfilldatabase/filldata.cpp

     
    27812781                  "DATE_SUB(CURRENT_DATE, INTERVAL :OFFSET DAY);");
    27822782    query.bindValue(":OFFSET", offset);
    27832783    query.exec();
    2784 
    2785     query.prepare("DELETE FROM record WHERE (type = :SINGLE "
    2786                   "OR type = :OVERRIDE OR type = :DONTRECORD) "
    2787                   "AND enddate < NOW();");
    2788     query.bindValue(":SINGLE", kSingleRecord);
    2789     query.bindValue(":OVERRIDE", kOverrideRecord);
    2790     query.bindValue(":DONTRECORD", kDontRecord);
    2791     query.exec();
    2792 
    2793     MSqlQuery findq(MSqlQuery::InitCon());
    2794     findq.prepare("SELECT record.recordid FROM record "
    2795                   "LEFT JOIN oldfind ON oldfind.recordid = record.recordid "
    2796                   "WHERE type = :FINDONE AND oldfind.findid IS NOT NULL;");
    2797     findq.bindValue(":FINDONE", kFindOneRecord);
    2798     findq.exec();
    2799        
    2800     if (findq.isActive() && findq.size() > 0)
    2801     {
    2802         while (findq.next())
    2803         {
    2804             query.prepare("DELETE FROM record WHERE recordid = :RECORDID;");
    2805             query.bindValue(":RECORDID", findq.value(0).toInt());
    2806             query.exec();
    2807         }
    2808     }
    2809     query.prepare("DELETE FROM oldfind WHERE findid < TO_DAYS(NOW()) - 14;");
    2810     query.exec();
    2811 
    2812     int cleanOldRecorded = gContext->GetNumSetting( "CleanOldRecorded", 10);
    2813 
    2814     query.prepare("DELETE FROM oldrecorded WHERE "
    2815                   "recstatus <> :RECORDED AND duplicate = 0 AND "
    2816                   "endtime < DATE_SUB(CURRENT_DATE, INTERVAL :CLEAN DAY);");
    2817     query.bindValue(":RECORDED", rsRecorded);
    2818     query.bindValue(":CLEAN", cleanOldRecorded);
    2819     query.exec();
    28202784}
    28212785
    28222786/** \fn fillData(QValueList<Source> &sourcelist)