Mercurial > hg > orthanc
diff OrthancServer/Sources/ResourceFinder.cpp @ 5835:7c61bdf925fc find-refactoring
simplified limit handling + Limit argument is now clipped by LimitFindResults
author | Alain Mazy <am@orthanc.team> |
---|---|
date | Mon, 14 Oct 2024 15:47:51 +0200 |
parents | 963945d780d6 |
children | 82fc95cc168c |
line wrap: on
line diff
--- a/OrthancServer/Sources/ResourceFinder.cpp Wed Oct 09 10:23:04 2024 +0200 +++ b/OrthancServer/Sources/ResourceFinder.cpp Mon Oct 14 15:47:51 2024 +0200 @@ -474,49 +474,72 @@ void ResourceFinder::UpdateRequestLimits() { - // By default, use manual paging - pagingMode_ = PagingMode_FullManual; + if (true) // simplified code by AM by probably missing a few things ... + { + // By default, use manual paging + pagingMode_ = PagingMode_FullDatabase; - if (databaseLimits_ != 0) - { - request_.SetLimits(0, databaseLimits_ + 1); + if (hasLimitsSince_ || hasLimitsCount_) + { + pagingMode_ = PagingMode_FullDatabase; + if (databaseLimits_ != 0 && limitsCount_ > databaseLimits_) + { + LOG(WARNING) << "ResourceFinder: 'Limit' is larger than LimitFindResults/LimitFindInstances configurations, using limit fron the configuration file"; + limitsCount_ = databaseLimits_; + } + + request_.SetLimits(limitsSince_, limitsCount_); + } + else if (databaseLimits_ != 0) + { + request_.SetLimits(0, databaseLimits_); + } + } else { - request_.ClearLimits(); - } - - if (lookup_.get() == NULL && - (hasLimitsSince_ || hasLimitsCount_)) - { - pagingMode_ = PagingMode_FullDatabase; - request_.SetLimits(limitsSince_, limitsCount_); - } + // By default, use manual paging + pagingMode_ = PagingMode_FullManual; - if (lookup_.get() != NULL && - isSimpleLookup_ && - (hasLimitsSince_ || hasLimitsCount_)) - { - /** - * TODO-FIND: "IDatabaseWrapper::ApplyLookupResources()" only - * accept the "limit" argument. The "since" must be implemented - * manually. - **/ - - if (hasLimitsSince_ && - limitsSince_ != 0) + if (databaseLimits_ != 0) { - pagingMode_ = PagingMode_ManualSkip; - request_.SetLimits(0, limitsCount_ + limitsSince_); + request_.SetLimits(0, databaseLimits_ + 1); } else { + request_.ClearLimits(); + } + + if (lookup_.get() == NULL && + (hasLimitsSince_ || hasLimitsCount_)) + { pagingMode_ = PagingMode_FullDatabase; - request_.SetLimits(0, limitsCount_); + request_.SetLimits(limitsSince_, limitsCount_); + } + + if (lookup_.get() != NULL && + isSimpleLookup_ && + (hasLimitsSince_ || hasLimitsCount_)) + { + /** + * TODO-FIND: "IDatabaseWrapper::ApplyLookupResources()" only + * accept the "limit" argument. The "since" must be implemented + * manually. + **/ + + if (hasLimitsSince_ && + limitsSince_ != 0) + { + pagingMode_ = PagingMode_ManualSkip; + request_.SetLimits(0, limitsCount_ + limitsSince_); + } + else + { + pagingMode_ = PagingMode_FullDatabase; + request_.SetLimits(0, limitsCount_); + } } } - - // TODO-FIND: More cases could be added, depending on "GetDatabaseCapabilities()" }