Ticket #11541: 0003-simplify-handling-of-missing-endtime-at-end-of-file-.patch

File 0003-simplify-handling-of-missing-endtime-at-end-of-file-.patch, 3.6 KB (added by Karl Egly, 6 years ago)

untested patch to simplify the endtime fixup instead of keeping it complicated

  • mythtv/libs/libmythtv/programdata.cpp

    From d0dc8f6f1fd80b5ce16d21c5c405d4435a0ea9bf Mon Sep 17 00:00:00 2001
    From: Karl Dietz <dekarl@mythtv.org>
    Date: Wed, 2 Apr 2014 20:00:53 +0200
    Subject: [PATCH 3/3] simplify handling of missing endtime at end of file in
     mythfilldatabase
    
    Instead of making up endtime of "next midnight" and "next 06:00 am" we
    just let the database fill in its default of 0000-00-00 00:00 and replace
    it later with whatever the next starttime is on that channel.
    
    Fixes #11541
    ---
     mythtv/libs/libmythtv/programdata.cpp |   34 ++++++++-------------------------
     1 file changed, 8 insertions(+), 26 deletions(-)
    
    diff --git a/mythtv/libs/libmythtv/programdata.cpp b/mythtv/libs/libmythtv/programdata.cpp
    index 7559fc9..0ddd7f4 100644
    a b void ProgramData::FixProgramList(QList<ProgInfo*> &fixlist) 
    10141014                (*cur)->endts   = (*it)->startts;
    10151015                (*cur)->endtime = (*it)->starttime;
    10161016            }
    1017             else
    1018             {
    1019                 (*cur)->endtime = (*cur)->starttime;
    1020                 if ((*cur)->endtime < QDateTime(
    1021                         (*cur)->endtime.date(), QTime(6, 0), Qt::UTC))
    1022                 {
    1023                     (*cur)->endtime = QDateTime(
    1024                         (*cur)->endtime.date(), QTime(6, 0), Qt::UTC);
    1025                 }
    1026                 else
    1027                 {
    1028                     (*cur)->endtime = QDateTime(
    1029                         (*cur)->endtime.date().addDays(1),
    1030                         QTime(0, 0), Qt::UTC);
    1031                 }
    1032 
    1033                 (*cur)->endts =
    1034                     MythDate::toString((*cur)->endtime, MythDate::kFilename);
    1035             }
     1017            /* if its the last programme in the file then leave its
     1018               endtime as 0000-00-00 00:00 so we can find it easily in
     1019               fix_end_times() */
    10361020        }
    10371021
    10381022        if (it == fixlist.end())
    int ProgramData::fix_end_times(void) 
    11691153    MSqlQuery query1(MSqlQuery::InitCon()), query2(MSqlQuery::InitCon());
    11701154
    11711155    querystr = "SELECT chanid, starttime, endtime FROM program "
    1172                "WHERE (DATE_FORMAT(endtime,'%H%i') = '0000') "
     1156               "WHERE endtime = '0000-00-00 00:00:00') "
    11731157               "ORDER BY chanid, starttime;";
    11741158
    11751159    if (!query1.exec(querystr))
    int ProgramData::fix_end_times(void) 
    11861170        endtime = query1.value(2).toString();
    11871171
    11881172        querystr = QString("SELECT chanid, starttime, endtime FROM program "
    1189                            "WHERE starttime BETWEEN '%1 00:00:00'"
    1190                            "AND '%2 23:59:59' AND chanid = '%3' "
     1173                           "WHERE starttime > '%1' "
     1174                           "AND chanid = '%2' "
    11911175                           "ORDER BY starttime LIMIT 1;")
    1192                            .arg(endtime.left(10))
    1193                            .arg(endtime.left(10))
     1176                           .arg(starttime)
    11941177                           .arg(chanid);
    11951178
    11961179        if (!query2.exec(querystr))
    int ProgramData::fix_end_times(void) 
    12041187        {
    12051188            count++;
    12061189            endtime = query2.value(1).toString();
    1207             querystr = QString("UPDATE program SET starttime = '%1', "
     1190            querystr = QString("UPDATE program SET "
    12081191                               "endtime = '%2' WHERE (chanid = '%3' AND "
    12091192                               "starttime = '%4');")
    1210                                .arg(starttime)
    12111193                               .arg(endtime)
    12121194                               .arg(chanid)
    12131195                               .arg(starttime);