def getAll()

in api/src/main/scala/com/gu/core/store/store.scala [93:111]


  def getAll(user: User): Either[Error, FoundAvatars] = {
    def loop(acc: List[Avatar], since: Option[DateTime]): Either[Error, FoundAvatars] = {
      val resp = kvs.query(
        dynamoTable,
        userIndex,
        user.id,
        since,
        None
      )

      resp match {
        case Right(found) if found.hasMore => loop(acc ::: found.avatars, found.avatars.lastOption.map(_.lastModified))
        case Right(last) => Right(FoundAvatars(body = acc ::: last.avatars, hasMore = false))
        case Left(error) => Left(error)
      }
    }

    loop(Nil, None)
  }