Mercurial > hg > orthanc
diff OrthancServer/ServerIndex.cpp @ 646:fb49bf72ac2d
fix issue #7
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 30 Oct 2013 08:58:45 +0100 |
parents | ec0b7a51d7bd |
children | 08eca5d86aad |
line wrap: on
line diff
--- a/OrthancServer/ServerIndex.cpp Tue Oct 29 20:32:24 2013 +0100 +++ b/OrthancServer/ServerIndex.cpp Wed Oct 30 08:58:45 2013 +0100 @@ -1301,26 +1301,22 @@ } - void ServerIndex::GetStatistics(Json::Value& target, - const std::string& publicId) + void ServerIndex::GetStatisticsInternal(/* out */ uint64_t& compressedSize, + /* out */ uint64_t& uncompressedSize, + /* out */ unsigned int& countStudies, + /* out */ unsigned int& countSeries, + /* out */ unsigned int& countInstances, + /* in */ int64_t id, + /* in */ ResourceType type) { - boost::mutex::scoped_lock lock(mutex_); + std::stack<int64_t> toExplore; + toExplore.push(id); - ResourceType type; - int64_t top; - if (!db_->LookupResource(publicId, top, type)) - { - throw OrthancException(ErrorCode_UnknownResource); - } - - std::stack<int64_t> toExplore; - toExplore.push(top); - - int countInstances = 0; - int countSeries = 0; - int countStudies = 0; - uint64_t compressedSize = 0; - uint64_t uncompressedSize = 0; + countInstances = 0; + countSeries = 0; + countStudies = 0; + compressedSize = 0; + uncompressedSize = 0; while (!toExplore.empty()) { @@ -1375,6 +1371,39 @@ } } + if (countStudies == 0) + { + countStudies = 1; + } + + if (countSeries == 0) + { + countSeries = 1; + } + } + + + + void ServerIndex::GetStatistics(Json::Value& target, + const std::string& publicId) + { + boost::mutex::scoped_lock lock(mutex_); + + ResourceType type; + int64_t top; + if (!db_->LookupResource(publicId, top, type)) + { + throw OrthancException(ErrorCode_UnknownResource); + } + + uint64_t uncompressedSize; + uint64_t compressedSize; + unsigned int countStudies; + unsigned int countSeries; + unsigned int countInstances; + GetStatisticsInternal(compressedSize, uncompressedSize, countStudies, + countSeries, countInstances, top, type); + target = Json::objectValue; target["DiskSize"] = boost::lexical_cast<std::string>(compressedSize); target["DiskSizeMB"] = boost::lexical_cast<unsigned int>(compressedSize / MEGA_BYTES); @@ -1400,6 +1429,27 @@ } + void ServerIndex::GetStatistics(/* out */ uint64_t& compressedSize, + /* out */ uint64_t& uncompressedSize, + /* out */ unsigned int& countStudies, + /* out */ unsigned int& countSeries, + /* out */ unsigned int& countInstances, + const std::string& publicId) + { + boost::mutex::scoped_lock lock(mutex_); + + ResourceType type; + int64_t top; + if (!db_->LookupResource(publicId, top, type)) + { + throw OrthancException(ErrorCode_UnknownResource); + } + + GetStatisticsInternal(compressedSize, uncompressedSize, countStudies, + countSeries, countInstances, top, type); + } + + void ServerIndex::UnstableResourcesMonitorThread(ServerIndex* that) { int stableAge = GetGlobalIntegerParameter("StableAge", 60);