Ticket #6589: mythtv-6589-backend_status-add_livetv_deleted_and_expirable_to_total_space-separate_summary_and_details.patch

File mythtv-6589-backend_status-add_livetv_deleted_and_expirable_to_total_space-separate_summary_and_details.patch, 3.5 KB (added by sphery <mtdean@…>, 3 years ago)

Adds auto-expire space usage to Total Disk Space. Apply on top of (after) mythtv-6589-backend_status-split_total_and_detailed_storage_info.patch

  • programs/mythbackend/httpstatus.cpp

    old new  
    366366        group.setAttribute("dir"  , directory ); 
    367367 
    368368        if (fsID == "total") 
     369        { 
     370            long long iLiveTV = -1, iDeleted = -1, iExpirable = -1; 
     371            MSqlQuery query(MSqlQuery::InitCon()); 
     372            query.prepare("SELECT SUM(filesize) FROM recorded " 
     373                          " WHERE recgroup = :RECGROUP;"); 
     374 
     375            query.bindValue("RECGROUP", "LiveTV"); 
     376            if (query.exec() && (query.size() > 0) && query.next()) 
     377            { 
     378                iLiveTV = query.value(0).toLongLong(); 
     379            } 
     380            query.bindValue("RECGROUP", "Deleted"); 
     381            if (query.exec() && (query.size() > 0) && query.next()) 
     382            { 
     383                iDeleted = query.value(0).toLongLong(); 
     384            } 
     385            query.prepare("SELECT SUM(filesize) FROM recorded " 
     386                          " WHERE autoexpire = 1 " 
     387                          "   AND recgroup NOT IN ('LiveTV', 'Deleted');"); 
     388            if (query.exec() && (query.size() > 0) && query.next()) 
     389            { 
     390                iExpirable = query.value(0).toLongLong(); 
     391            } 
     392            group.setAttribute("livetv", (int)(iLiveTV>>20) ); 
     393            group.setAttribute("deleted", (int)(iDeleted>>20) ); 
     394            group.setAttribute("expirable", (int)(iExpirable>>20) ); 
    369395            total = group; 
     396        } 
    370397        else 
    371398            fsXML << group; 
    372399    } 
     
    11271154                int nFree    = g.attribute("free" , "0" ).toInt(); 
    11281155                int nTotal   = g.attribute("total", "0" ).toInt(); 
    11291156                int nUsed    = g.attribute("used" , "0" ).toInt(); 
     1157                int nLiveTV    = g.attribute("livetv" , "0" ).toInt(); 
     1158                int nDeleted   = g.attribute("deleted", "0" ).toInt(); 
     1159                int nExpirable = g.attribute("expirable" , "0" ).toInt(); 
    11301160                QString nDir = g.attribute("dir"  , "" ); 
    11311161 
    11321162                nDir.replace(QRegExp(","), ", "); 
     
    11501180                sRep = c.toString(nFree) + " MB"; 
    11511181                os << sRep << "</li>\r\n"; 
    11521182 
     1183                if ((nLiveTV + nDeleted + nExpirable) > 0) 
     1184                { 
     1185                    os << "            <li>Space Available " 
     1186                          "After Auto-expire: "; 
     1187                    sRep = c.toString(nFree + nLiveTV + 
     1188                                      nDeleted + nExpirable) + " MB"; 
     1189                    os << sRep << "</li>\r\n"; 
     1190                    os << "            <ul>\r\n"; 
     1191                    os << "              <li>Space Used by LiveTV: "; 
     1192                    sRep = c.toString(nLiveTV) + " MB"; 
     1193                    os << sRep << "</li>\r\n"; 
     1194                    os << "              <li>Space Used by " 
     1195                          "Deleted Recordings: "; 
     1196                    sRep = c.toString(nDeleted) + " MB"; 
     1197                    os << sRep << "</li>\r\n"; 
     1198                    os << "              <li>Space Used by " 
     1199                          "Auto-expirable Recordings: "; 
     1200                    sRep = c.toString(nExpirable) + " MB"; 
     1201                    os << sRep << "</li>\r\n"; 
     1202                    os << "            </ul>\r\n"; 
     1203                } 
     1204 
    11531205                os << "          </ul>\r\n" 
    11541206                << "        </li>\r\n"; 
    11551207