comparison Framework/Plugins/IndexBackend.cpp @ 580:35d2df9572b1 find-refactoring

count-resources
author Alain Mazy <am@orthanc.team>
date Tue, 15 Oct 2024 15:52:39 +0200
parents 77c8544bbd7d
children a80775ee5eea
comparison
equal deleted inserted replaced
578:e99ca3508757 580:35d2df9572b1
3185 #define QUERY_ONE_INSTANCE_ATTACHMENTS 52 3185 #define QUERY_ONE_INSTANCE_ATTACHMENTS 52
3186 3186
3187 #define STRINGIFY(x) #x 3187 #define STRINGIFY(x) #x
3188 #define TOSTRING(x) STRINGIFY(x) 3188 #define TOSTRING(x) STRINGIFY(x)
3189 3189
3190 void IndexBackend::ExecuteCount(Orthanc::DatabasePluginMessages::TransactionResponse& response,
3191 DatabaseManager& manager,
3192 const Orthanc::DatabasePluginMessages::Find_Request& request)
3193 {
3194 std::string sql;
3195
3196 LookupFormatter formatter(manager.GetDialect());
3197 std::string lookupSql;
3198 ISqlLookupFormatter::Apply(lookupSql, formatter, request);
3199
3200 sql = "WITH Lookup AS (" + lookupSql + ") SELECT COUNT(*) FROM Lookup";
3201
3202 DatabaseManager::StandaloneStatement statement(manager, sql); // TODO-FIND: cache dynamic statement ? Probably worth it since it can be very complex queries !
3203 formatter.PrepareStatement(statement);
3204 statement.Execute(formatter.GetDictionary());
3205 response.mutable_count_resources()->set_count(statement.ReadInteger64(0));
3206 }
3207
3190 void IndexBackend::ExecuteFind(Orthanc::DatabasePluginMessages::TransactionResponse& response, 3208 void IndexBackend::ExecuteFind(Orthanc::DatabasePluginMessages::TransactionResponse& response,
3191 DatabaseManager& manager, 3209 DatabaseManager& manager,
3192 const Orthanc::DatabasePluginMessages::Find_Request& request) 3210 const Orthanc::DatabasePluginMessages::Find_Request& request)
3193 { 3211 {
3194 // TODO-FIND move to child plugins ? 3212 // TODO-FIND move to child plugins ?