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

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

Adds auto-expire usage information to "Total Disk Space". Use alone and only if not moving "Total Disk Space" to the top. (Not for use with other patches.)

  • programs/mythbackend/httpstatus.cpp

    old new  
    364364 
    365365        // Make sure that the total is always the last element. 
    366366        if (fsID == "total") 
     367        { 
     368            long long iLiveTV = -1, iDeleted = -1, iExpirable = -1; 
     369            MSqlQuery query(MSqlQuery::InitCon()); 
     370            query.prepare("SELECT SUM(filesize) FROM recorded " 
     371                          " WHERE recgroup = :RECGROUP;"); 
     372 
     373            query.bindValue("RECGROUP", "LiveTV"); 
     374            if (query.exec() && (query.size() > 0) && query.next()) 
     375            { 
     376                iLiveTV = query.value(0).toLongLong(); 
     377            } 
     378            query.bindValue("RECGROUP", "Deleted"); 
     379            if (query.exec() && (query.size() > 0) && query.next()) 
     380            { 
     381                iDeleted = query.value(0).toLongLong(); 
     382            } 
     383            query.prepare("SELECT SUM(filesize) FROM recorded " 
     384                          " WHERE autoexpire = 1 " 
     385                          "   AND recgroup NOT IN ('LiveTV', 'Deleted');"); 
     386            if (query.exec() && (query.size() > 0) && query.next()) 
     387            { 
     388                iExpirable = query.value(0).toLongLong(); 
     389            } 
     390            group.setAttribute("livetv", (int)(iLiveTV>>20) ); 
     391            group.setAttribute("deleted", (int)(iDeleted>>20) ); 
     392            group.setAttribute("expirable", (int)(iExpirable>>20) ); 
    367393            total = group; 
     394        } 
    368395        else 
    369396            storage.appendChild(group); 
    370397    } 
     
    11561183            sRep = c.toString(nFree) + " MB"; 
    11571184            os << sRep << "</li>\r\n"; 
    11581185 
     1186            if (id == "total") 
     1187            { 
     1188                int nLiveTV    = g.attribute("livetv" , "0" ).toInt(); 
     1189                int nDeleted   = g.attribute("deleted", "0" ).toInt(); 
     1190                int nExpirable = g.attribute("expirable" , "0" ).toInt(); 
     1191                if ((nLiveTV + nDeleted + nExpirable) > 0) 
     1192                { 
     1193                    os << "            <li>Space Available " 
     1194                          "After Auto-expire: "; 
     1195                    sRep = c.toString(nFree + nLiveTV + 
     1196                                      nDeleted + nExpirable) + " MB"; 
     1197                    os << sRep << "</li>\r\n"; 
     1198                    os << "            <ul>\r\n"; 
     1199                    os << "              <li>Space Used by LiveTV: "; 
     1200                    sRep = c.toString(nLiveTV) + " MB"; 
     1201                    os << sRep << "</li>\r\n"; 
     1202                    os << "              <li>Space Used by " 
     1203                          "Deleted Recordings: "; 
     1204                    sRep = c.toString(nDeleted) + " MB"; 
     1205                    os << sRep << "</li>\r\n"; 
     1206                    os << "              <li>Space Used by " 
     1207                          "Auto-expirable Recordings: "; 
     1208                    sRep = c.toString(nExpirable) + " MB"; 
     1209                    os << sRep << "</li>\r\n"; 
     1210                    os << "            </ul>\r\n"; 
     1211                } 
     1212            } 
     1213 
    11591214            os << "          </ul>\r\n" 
    11601215            << "        </li>\r\n"; 
    11611216