> Thanks for your answer Mirco!
>
> hmm, I think its very often the case that its required to do some stuff on the result of a db-query?
>
> e.g. right now my action looks like this
>
> def index = Action.async {
> val query: DBIO[Seq[Details]] = sql"""SELECT
> id, request_id, now,
> remote_address, user_agent, status,
> signature, data, returncode, response, nanotime
> FROM json_log ORDER BY id DESC LIMIT 60""".as[Details]
>
> val data: Future[Map[String, Seq[Details]]] = dbConfig.db.run(query).map(a => a.seq.groupBy(b => b.now.getTime.toString.substring(0, 10) +"_"+ b.requestId))
> data.map(a => Ok(views.html.sysadmin.browseCollectorLog.index
> (a)))
> }
>
> just for mapping the query-future to the thing I need in my View I already need an ExecutionContext ... even when not using the transformation I'm doing, I think I would need the last map operation to render the view so I can fulfill the contract of Action.async ?
You are right - it was late when I answered and haven’t really thought it through :-)
> Maybe I understood something wrong?
>
>
> What happens if I attach the map to the query itself, like
>
> val data: Future[Map[String, Seq[Details]]] = dbConfig.db.run(query.map(a => a.seq.groupBy(b => b.now.getTime.toString.substring(0, 10) +"_"+ b.requestId)))
> ?
> Will the transformation be done in the ExecutionContext of Slick or the one of Play?
To know that, you should check the signature of the methods you are calling. For instance, the `query.map` expression in your code takes two arguments: a function, and an implicit ExecutionContext. Therefore, the function application will be executed on the ExecutionContext that you make available in the scope of that expression (entailing that it won’t be executed using the Slick managed thread pool, unless of course you explicitly import the Slick execution context in the current scope - don’t do that :-)). This makes sense as you want the Slick thread pool to be available to execute db actions.
> Does it actually matter? Maybe I'm too much concerned about a thing that's not worth thinking about?
I think you are asking really good questions, and I’d definitely say these are aspects worth thinking about.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/play-framework/CABHM76UynbOuaOcmgXCm48B7saS9ntWbmZHMn3-49Bjse144SQ%40mail.gmail.com.