Ticket #3842: 3842-add-new-column-trunk-v1.patch
| File 3842-add-new-column-trunk-v1.patch, 10.7 KB (added by , 18 years ago) |
|---|
-
libs/libmythtv/dbcheck.cpp
11 11 #include "datadirect.h" // for DataDirectProcessor::FixProgramIDs 12 12 13 13 /// This is the DB schema version expected by the running MythTV instance. 14 const QString currentDatabaseVersion = "1 199";14 const QString currentDatabaseVersion = "1200"; 15 15 16 16 static bool UpdateDBVersionNumber(const QString &newnumber); 17 17 static bool performActualUpdate(const QString updates[], QString version, … … 294 294 airing. If this is "0" it usually means that this is a brand new show 295 295 or a rebroadcast within the first two weeks. 296 296 297 'isnew' is a field that tells us if a listings source has marked this 298 program as a first showing of a program. 299 297 300 'programid' is the Tribune Media Service database record identifier 298 301 for each program description. In general, these start with a two 299 302 letter prefix, MV, EP, SP or SH that equate to the 'category_type'. … … 3247 3250 return false; 3248 3251 } 3249 3252 3253 if (dbver == "1199") 3254 { 3255 const QString updates[] = { 3256 "ALTER TABLE recorded ADD COLUMN isnew TINYINT(1) DEFAULT 0;", 3257 "ALTER TABLE recordedprogram ADD COLUMN isnew TINYINT(1) DEFAULT 0;", 3258 "ALTER TABLE program ADD COLUMN isnew TINYINT(1) DEFAULT 0;", 3259 "ALTER TABLE program ADD INDEX (isnew);", 3260 "" 3261 }; 3262 if (!performActualUpdate(updates, "1200", dbver)) 3263 return false; 3264 } 3265 3250 3266 //"ALTER TABLE cardinput DROP COLUMN preference;" in 0.22 3251 3267 //"ALTER TABLE channel DROP COLUMN atscsrcid;" in 0.22 3252 3268 //"ALTER TABLE recordedmarkup DROP COLUMN offset;" in 0.22 -
libs/libmythtv/datadirect.h
97 97 QString stationid; // 12 98 98 QDateTime time; 99 99 QTime duration; 100 bool repeat;101 100 bool isnew; 102 101 bool stereo; 103 102 bool subtitled; … … 217 216 { 218 217 public: 219 218 DDStructureParser(DataDirectProcessor& _ddparent) : 220 parent(_ddparent) , saw_repeat(false), saw_new(false){}219 parent(_ddparent) {} 221 220 222 221 bool startElement(const QString &pnamespaceuri, const QString &plocalname, 223 222 const QString &pqname, const QXmlAttributes &pxmlatts); … … 242 241 DataDirectProductionCrew curr_productioncrew; 243 242 DataDirectGenre curr_genre; 244 243 QString lastprogramid; 245 bool saw_repeat;246 bool saw_new;247 244 }; 248 245 249 246 -
libs/libmythtv/datadirect.cpp
68 68 DataDirectSchedule::DataDirectSchedule() : 69 69 programid(""), stationid(""), 70 70 time(QDateTime()), duration(QTime()), 71 repeat(false),isnew(false),71 isnew(false), 72 72 stereo(false), subtitled(false), 73 73 hdtv(false), closecaptioned(false), 74 74 tvrating(""), … … 168 168 curr_schedule.duration = QTime(durstr.mid(2, 2).toInt(), 169 169 durstr.mid(5, 2).toInt(), 0, 0); 170 170 171 QString isrepeat = pxmlatts.value("repeat"); 172 curr_schedule.repeat = (isrepeat == "true"); 173 saw_repeat |= !isrepeat.isEmpty(); 174 175 QString isnew = pxmlatts.value("new"); 176 curr_schedule.isnew = (isnew == "true"); 177 saw_new |= !isnew.isEmpty(); 178 171 curr_schedule.isnew = (pxmlatts.value("new") == "true"); 179 172 curr_schedule.stereo = (pxmlatts.value("stereo") == "true"); 180 173 curr_schedule.subtitled = (pxmlatts.value("subtitled") == "true"); 181 174 curr_schedule.hdtv = (pxmlatts.value("hdtv") == "true"); … … 283 276 query.prepare( 284 277 "INSERT INTO dd_schedule " 285 278 " ( programid, stationid, scheduletime, " 286 " duration, is repeat,stereo, "279 " duration, isnew, stereo, " 287 280 " subtitled, hdtv, closecaptioned, " 288 281 " tvrating, partnumber, parttotal, " 289 " endtime , isnew) "282 " endtime ) " 290 283 "VALUES " 291 284 " (:PROGRAMID, :STATIONID, :TIME, " 292 " :DURATION, :IS REPEAT,:STEREO, "285 " :DURATION, :ISNEW, :STEREO, " 293 286 " :SUBTITLED, :HDTV, :CAPTIONED, " 294 287 " :TVRATING, :PARTNUMBER, :PARTTOTAL, " 295 " :ENDTIME , :ISNEW)");288 " :ENDTIME )"); 296 289 297 290 query.bindValue(":PROGRAMID", curr_schedule.programid); 298 291 query.bindValue(":STATIONID", curr_schedule.stationid); 299 292 query.bindValue(":TIME", curr_schedule.time); 300 293 query.bindValue(":DURATION", curr_schedule.duration); 301 query.bindValue(":ISREPEAT", curr_schedule.repeat);302 294 query.bindValue(":STEREO", curr_schedule.stereo); 303 295 query.bindValue(":SUBTITLED", curr_schedule.subtitled); 304 296 query.bindValue(":HDTV", curr_schedule.hdtv); … … 420 412 421 413 bool DDStructureParser::endDocument() 422 414 { 423 MSqlQuery query(MSqlQuery::DDCon());424 query.prepare(425 "INSERT INTO dd_state (sawrepeat, sawnew) "426 "VALUES (:SAWREPEAT, :SAWNEW)");427 query.bindValue(":SAWREPEAT", saw_repeat);428 query.bindValue(":SAWNEW", saw_new);429 430 if (!query.exec())431 MythContext::DBError("Inserting into dd_state", query);432 433 415 return true; 434 416 } 435 417 … … 616 598 void DataDirectProcessor::UpdateProgramViewTable(uint sourceid) 617 599 { 618 600 MSqlQuery query(MSqlQuery::DDCon()); 619 620 query.prepare( 621 "SELECT sawrepeat, sawnew " 622 "FROM dd_state"); 623 624 if (!query.exec()) 625 { 626 MythContext::DBError("Querying into dd_state", query); 627 return; 628 } 629 630 if (!query.next()) 631 { 632 VERBOSE(VB_IMPORTANT, LOC_ERR + "UpdateProgramViewTable no dd_state!"); 633 return; 634 } 635 636 bool saw_repeat = query.value(0).toUInt(); (void) saw_repeat; 637 bool saw_new = query.value(1).toUInt(); (void) saw_new; 638 639 // VERBOSE(VB_GENERAL, LOC + QString("Saw new: %1, saw repeat: %2") 640 // .arg(saw_new).arg(saw_repeat)); 641 601 642 602 if (!query.exec("TRUNCATE TABLE dd_v_program;")) 643 603 MythContext::DBError("Truncating temporary table dd_v_program", query); 644 604 … … 646 606 "INSERT INTO dd_v_program " 647 607 " ( chanid, starttime, endtime, " 648 608 " title, subtitle, description, " 649 " airdate, stars, previouslyshown, "609 " airdate, stars, isnew, " 650 610 " stereo, subtitled, hdtv, " 651 611 " closecaptioned, partnumber, parttotal, " 652 612 " seriesid, originalairdate, showtype, " … … 654 614 " tvrating, mpaarating, programid ) " 655 615 "SELECT chanid, scheduletime, endtime, " 656 616 " title, subtitle, description, " 657 " year, stars, %1,"617 " year, stars, isnew, " 658 618 " stereo, subtitled, hdtv, " 659 619 " closecaptioned, partnumber, parttotal, " 660 620 " seriesid, originalairdate, showtype, " … … 665 625 " (channel.xmltvid = dd_schedule.stationid) AND " 666 626 " (channel.sourceid = :SOURCEID))"; 667 627 668 QString repeat = (saw_new) ? 669 "(not isnew) AND " 670 "(SUBSTRING(dd_program.programid,1,2) IN ('EP', 'SH'))" : 671 "isrepeat"; 628 query.prepare(qstr); 672 629 673 query.prepare(qstr.arg(repeat));674 675 630 query.bindValue(":SOURCEID", sourceid); 676 631 677 632 if (!query.exec()) … … 847 802 if (!query.exec("INSERT IGNORE INTO program (chanid, starttime, endtime, " 848 803 "title, subtitle, description, " 849 804 "showtype, category, category_type, " 850 "airdate, stars, previouslyshown, stereo, subtitled, "805 "airdate, stars, isnew, stereo, subtitled, " 851 806 "hdtv, closecaptioned, partnumber, parttotal, seriesid, " 852 807 "originalairdate, colorcode, syndicatedepisodenumber, " 853 808 "programid) " … … 856 811 "DATE_ADD(endtime, INTERVAL channel.tmoffset MINUTE), " 857 812 "title, subtitle, description, " 858 813 "showtype, dd_genre.class, category_type, " 859 "airdate, stars, previouslyshown, stereo, subtitled, "814 "airdate, stars, isnew, stereo, subtitled, " 860 815 "hdtv, closecaptioned, partnumber, parttotal, seriesid, " 861 816 "originalairdate, colorcode, syndicatedepisodenumber, " 862 817 "dd_v_program.programid FROM (dd_v_program, channel) " … … 1316 1271 { 1317 1272 QMap<QString,QString> dd_tables; 1318 1273 1319 dd_tables["dd_state"] =1320 "( sawrepeat bool, sawnew bool )";1321 1322 1274 dd_tables["dd_station"] = 1323 1275 "( stationid char(12), callsign char(10), " 1324 1276 " stationname varchar(40), affiliate varchar(25), " … … 1343 1295 dd_tables["dd_schedule"] = 1344 1296 "( programid char(40), stationid char(12), " 1345 1297 " scheduletime datetime, duration time, " 1346 " is repeat bool, stereo bool, "1298 " isnew tinyint, stereo bool, " 1347 1299 " subtitled bool, hdtv bool, " 1348 1300 " closecaptioned bool, tvrating char(5), " 1349 1301 " partnumber int, parttotal int, " 1350 " endtime datetime, isnew bool,"1302 " endtime datetime, " 1351 1303 "INDEX progidx (programid) )"; 1352 1304 1353 1305 dd_tables["dd_program"] = … … 1367 1319 " subtitle varchar(128), description text, " 1368 1320 " category varchar(64), category_type varchar(64), " 1369 1321 " airdate year, stars float unsigned, " 1370 " previouslyshown tinyint, isrepeat bool,"1322 " isnew tinyint, " 1371 1323 " stereo bool, subtitled bool, " 1372 1324 " hdtv bool, closecaptioned bool, " 1373 1325 " partnumber int, parttotal int, "
