mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-21 09:58:26 +00:00
Replace hardcoded number by a config value
This commit is contained in:
@ -17,6 +17,13 @@ docspell.server {
|
||||
port = 7880
|
||||
}
|
||||
|
||||
# This is a hard limit to restrict the size of a batch that is
|
||||
# returned when searching for items. The user can set this limit
|
||||
# within the client config, but it is restricted by the server to
|
||||
# the number defined here. An admin might choose a lower number
|
||||
# depending on the available resources.
|
||||
max-item-page-size = 500
|
||||
|
||||
# Authentication.
|
||||
auth {
|
||||
|
||||
|
@ -12,7 +12,8 @@ case class Config(
|
||||
bind: Config.Bind,
|
||||
backend: BackendConfig,
|
||||
auth: Login.Config,
|
||||
integrationEndpoint: Config.IntegrationEndpoint
|
||||
integrationEndpoint: Config.IntegrationEndpoint,
|
||||
maxItemPageSize: Int
|
||||
)
|
||||
|
||||
object Config {
|
||||
|
@ -69,7 +69,7 @@ object RestServer {
|
||||
"user" -> UserRoutes(restApp.backend, token),
|
||||
"collective" -> CollectiveRoutes(restApp.backend, token),
|
||||
"queue" -> JobQueueRoutes(restApp.backend, token),
|
||||
"item" -> ItemRoutes(restApp.backend, token),
|
||||
"item" -> ItemRoutes(cfg, restApp.backend, token),
|
||||
"attachment" -> AttachmentRoutes(restApp.backend, token),
|
||||
"upload" -> UploadRoutes.secured(restApp.backend, cfg, token),
|
||||
"checkfile" -> CheckFileRoutes.secured(restApp.backend, token),
|
||||
|
@ -13,12 +13,17 @@ import org.http4s.circe.CirceEntityDecoder._
|
||||
import docspell.restapi.model._
|
||||
import docspell.common.syntax.all._
|
||||
import docspell.restserver.conv.Conversions
|
||||
import docspell.restserver.Config
|
||||
import org.log4s._
|
||||
|
||||
object ItemRoutes {
|
||||
private[this] val logger = getLogger
|
||||
|
||||
def apply[F[_]: Effect](backend: BackendApp[F], user: AuthToken): HttpRoutes[F] = {
|
||||
def apply[F[_]: Effect](
|
||||
cfg: Config,
|
||||
backend: BackendApp[F],
|
||||
user: AuthToken
|
||||
): HttpRoutes[F] = {
|
||||
val dsl = new Http4sDsl[F] {}
|
||||
import dsl._
|
||||
|
||||
@ -31,7 +36,7 @@ object ItemRoutes {
|
||||
_ <- logger.ftrace(s"Running query: $query")
|
||||
items <- backend.item.findItems(
|
||||
query,
|
||||
Batch(mask.offset, mask.limit).restrictLimitTo(500)
|
||||
Batch(mask.offset, mask.limit).restrictLimitTo(cfg.maxItemPageSize)
|
||||
)
|
||||
resp <- Ok(Conversions.mkItemList(items))
|
||||
} yield resp
|
||||
@ -44,7 +49,7 @@ object ItemRoutes {
|
||||
_ <- logger.ftrace(s"Running query: $query")
|
||||
items <- backend.item.findItemsWithTags(
|
||||
query,
|
||||
Batch(mask.offset, mask.limit).restrictLimitTo(500)
|
||||
Batch(mask.offset, mask.limit).restrictLimitTo(cfg.maxItemPageSize)
|
||||
)
|
||||
resp <- Ok(Conversions.mkItemListWithTags(items))
|
||||
} yield resp
|
||||
|
Reference in New Issue
Block a user