Mercurial > hg > orthanc
comparison 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 |
comparison
equal
deleted
inserted
replaced
5832:dd2af8692cbc | 5835:7c61bdf925fc |
---|---|
472 } | 472 } |
473 | 473 |
474 | 474 |
475 void ResourceFinder::UpdateRequestLimits() | 475 void ResourceFinder::UpdateRequestLimits() |
476 { | 476 { |
477 // By default, use manual paging | 477 if (true) // simplified code by AM by probably missing a few things ... |
478 pagingMode_ = PagingMode_FullManual; | 478 { |
479 | 479 // By default, use manual paging |
480 if (databaseLimits_ != 0) | 480 pagingMode_ = PagingMode_FullDatabase; |
481 { | 481 |
482 request_.SetLimits(0, databaseLimits_ + 1); | 482 if (hasLimitsSince_ || hasLimitsCount_) |
483 { | |
484 pagingMode_ = PagingMode_FullDatabase; | |
485 if (databaseLimits_ != 0 && limitsCount_ > databaseLimits_) | |
486 { | |
487 LOG(WARNING) << "ResourceFinder: 'Limit' is larger than LimitFindResults/LimitFindInstances configurations, using limit fron the configuration file"; | |
488 limitsCount_ = databaseLimits_; | |
489 } | |
490 | |
491 request_.SetLimits(limitsSince_, limitsCount_); | |
492 } | |
493 else if (databaseLimits_ != 0) | |
494 { | |
495 request_.SetLimits(0, databaseLimits_); | |
496 } | |
497 | |
483 } | 498 } |
484 else | 499 else |
485 { | 500 { |
486 request_.ClearLimits(); | 501 // By default, use manual paging |
487 } | 502 pagingMode_ = PagingMode_FullManual; |
488 | 503 |
489 if (lookup_.get() == NULL && | 504 if (databaseLimits_ != 0) |
490 (hasLimitsSince_ || hasLimitsCount_)) | 505 { |
491 { | 506 request_.SetLimits(0, databaseLimits_ + 1); |
492 pagingMode_ = PagingMode_FullDatabase; | |
493 request_.SetLimits(limitsSince_, limitsCount_); | |
494 } | |
495 | |
496 if (lookup_.get() != NULL && | |
497 isSimpleLookup_ && | |
498 (hasLimitsSince_ || hasLimitsCount_)) | |
499 { | |
500 /** | |
501 * TODO-FIND: "IDatabaseWrapper::ApplyLookupResources()" only | |
502 * accept the "limit" argument. The "since" must be implemented | |
503 * manually. | |
504 **/ | |
505 | |
506 if (hasLimitsSince_ && | |
507 limitsSince_ != 0) | |
508 { | |
509 pagingMode_ = PagingMode_ManualSkip; | |
510 request_.SetLimits(0, limitsCount_ + limitsSince_); | |
511 } | 507 } |
512 else | 508 else |
513 { | 509 { |
510 request_.ClearLimits(); | |
511 } | |
512 | |
513 if (lookup_.get() == NULL && | |
514 (hasLimitsSince_ || hasLimitsCount_)) | |
515 { | |
514 pagingMode_ = PagingMode_FullDatabase; | 516 pagingMode_ = PagingMode_FullDatabase; |
515 request_.SetLimits(0, limitsCount_); | 517 request_.SetLimits(limitsSince_, limitsCount_); |
516 } | 518 } |
517 } | 519 |
518 | 520 if (lookup_.get() != NULL && |
519 // TODO-FIND: More cases could be added, depending on "GetDatabaseCapabilities()" | 521 isSimpleLookup_ && |
522 (hasLimitsSince_ || hasLimitsCount_)) | |
523 { | |
524 /** | |
525 * TODO-FIND: "IDatabaseWrapper::ApplyLookupResources()" only | |
526 * accept the "limit" argument. The "since" must be implemented | |
527 * manually. | |
528 **/ | |
529 | |
530 if (hasLimitsSince_ && | |
531 limitsSince_ != 0) | |
532 { | |
533 pagingMode_ = PagingMode_ManualSkip; | |
534 request_.SetLimits(0, limitsCount_ + limitsSince_); | |
535 } | |
536 else | |
537 { | |
538 pagingMode_ = PagingMode_FullDatabase; | |
539 request_.SetLimits(0, limitsCount_); | |
540 } | |
541 } | |
542 } | |
520 } | 543 } |
521 | 544 |
522 | 545 |
523 ResourceFinder::ResourceFinder(ResourceType level, | 546 ResourceFinder::ResourceFinder(ResourceType level, |
524 ResponseContentFlags responseContent) : | 547 ResponseContentFlags responseContent) : |