throttle study PGN export

russelldavis-analysis-material
Thibault Duplessis 2021-08-08 10:20:51 +02:00
parent ffb4edb9b0
commit e1de67ee02
2 changed files with 2 additions and 1 deletions

View File

@ -497,7 +497,6 @@ final class Study(
.withAttributes(
akka.stream.ActorAttributes.supervisionStrategy(akka.stream.Supervision.resumingDecider)
)
.throttle(30, 1 second)
} { source =>
Ok.chunked(source)
.pipe(asAttachmentStream(s"${username}-${if (isMe) "all" else "public"}-studies.pgn"))

View File

@ -4,6 +4,7 @@ import akka.stream.scaladsl._
import chess.format.pgn.{ Glyphs, Initial, Pgn, Tag, Tags }
import chess.format.{ pgn => chessPgn }
import org.joda.time.format.DateTimeFormat
import scala.concurrent.duration._
import scala.concurrent.ExecutionContext
import lila.common.String.slugify
@ -22,6 +23,7 @@ final class PgnDump(
def apply(study: Study, flags: WithFlags): Source[String, _] =
chapterRepo
.orderedByStudySource(study.id)
.throttle(16, 1 second)
.mapAsync(1)(ofChapter(study, flags))
def ofChapter(study: Study, flags: WithFlags)(chapter: Chapter): Fu[String] =