Skip to content

Instantly share code, notes, and snippets.

@yukihirai0505
Created November 15, 2017 08:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yukihirai0505/023ff92fea22138ea839b7e0ee00c15f to your computer and use it in GitHub Desktop.
Save yukihirai0505/023ff92fea22138ea839b7e0ee00c15f to your computer and use it in GitHub Desktop.
// dtoSeqを5000で分割して、それぞれに別々のトークンを付与する
protected def mapToken[T](dtoSeq: Seq[InstagramDto[T]], tokens: Seq[String]): Seq[InstagramDto[T]] = {
dtoSeq.grouped(5000).toSeq.zipWithIndex.flatMap {
case (d, i) => d.map { s =>
def getIndex(index: Int): Int = {
if (index < tokens.length) index
else getIndex(index - tokens.length)
}
s.copy(accessToken = Some(tokens(getIndex(i))))
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment