def loginsFor()

in app/controllers/LoginHistoryController.scala [71:89]


  def loginsFor(hostName:String, limit:Option[Int]) = Action.async {
    val client = esClientMgr.getClient()

    val actualLimit = limit match {
      case Some(lim)=>lim
      case None=>10
    }

    val resultFuture = client.execute {
      search(s"$loginsIndex/login") query {
        termQuery("hostname", hostName)
      } sortByFieldDesc "loginTime" limit actualLimit
    }

    resultFuture.map({
      case Left(err)=>InternalServerError(GenericErrorResponse("search_error", err.toString).asJson)
      case Right(results)=>Ok(ObjectListResponse("ok","login_history", results.result.to[RecentLogin], results.result.totalHits.toInt).asJson)
    })
  }