Mercurial > hg > orthanc
comparison OrthancServer/OrthancRestApi/OrthancRestResources.cpp @ 3174:8ea7c4546c3a
primitives to collect metrics in Orthanc
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 29 Jan 2019 15:15:48 +0100 |
parents | cf91b6f22278 |
children | 4bbadcd03966 |
comparison
equal
deleted
inserted
replaced
3173:096f4a29f223 | 3174:8ea7c4546c3a |
---|---|
643 call.GetOutput().AnswerBuffer(raw, mime); | 643 call.GetOutput().AnswerBuffer(raw, mime); |
644 } | 644 } |
645 } | 645 } |
646 | 646 |
647 | 647 |
648 | |
649 static void GetResourceStatistics(RestApiGetCall& call) | 648 static void GetResourceStatistics(RestApiGetCall& call) |
650 { | 649 { |
651 std::string publicId = call.GetUriComponent("id", ""); | 650 static const uint64_t MEGA_BYTES = 1024 * 1024; |
652 Json::Value result; | 651 |
653 OrthancRestApi::GetIndex(call).GetStatistics(result, publicId); | 652 std::string publicId = call.GetUriComponent("id", ""); |
653 | |
654 ResourceType type; | |
655 uint64_t diskSize, uncompressedSize, dicomDiskSize, dicomUncompressedSize; | |
656 unsigned int countStudies, countSeries, countInstances; | |
657 OrthancRestApi::GetIndex(call).GetResourceStatistics( | |
658 type, diskSize, uncompressedSize, countStudies, countSeries, | |
659 countInstances, dicomDiskSize, dicomUncompressedSize, publicId); | |
660 | |
661 Json::Value result = Json::objectValue; | |
662 result["DiskSize"] = boost::lexical_cast<std::string>(diskSize); | |
663 result["DiskSizeMB"] = static_cast<unsigned int>(diskSize / MEGA_BYTES); | |
664 result["UncompressedSize"] = boost::lexical_cast<std::string>(uncompressedSize); | |
665 result["UncompressedSizeMB"] = static_cast<unsigned int>(uncompressedSize / MEGA_BYTES); | |
666 | |
667 result["DicomDiskSize"] = boost::lexical_cast<std::string>(dicomDiskSize); | |
668 result["DicomDiskSizeMB"] = static_cast<unsigned int>(dicomDiskSize / MEGA_BYTES); | |
669 result["DicomUncompressedSize"] = boost::lexical_cast<std::string>(dicomUncompressedSize); | |
670 result["DicomUncompressedSizeMB"] = static_cast<unsigned int>(dicomUncompressedSize / MEGA_BYTES); | |
671 | |
672 switch (type) | |
673 { | |
674 // Do NOT add "break" below this point! | |
675 case ResourceType_Patient: | |
676 result["CountStudies"] = countStudies; | |
677 | |
678 case ResourceType_Study: | |
679 result["CountSeries"] = countSeries; | |
680 | |
681 case ResourceType_Series: | |
682 result["CountInstances"] = countInstances; | |
683 | |
684 case ResourceType_Instance: | |
685 default: | |
686 break; | |
687 } | |
688 | |
654 call.GetOutput().AnswerJson(result); | 689 call.GetOutput().AnswerJson(result); |
655 } | 690 } |
656 | 691 |
657 | 692 |
658 | 693 |