How an application built on Scala Play Framework is helping outdoor enthusiasts
A ScalaSyd presentation by Chris Cooper
http://chris-cooper.github.io/doarama-scala-syd/
Hmmm
Upload/Live Correlate Tweak Share Comment Web | API
What we have...
Sidney Shek / Clinton Freeman / Mark Hibberd / Eric Torreborre / Tony Morris
FP / Scala / Web / scoobi / specs2 etc..
$ git push heroku master
dev | stage | production
def listByUserId(user_id: Long, page: Int = 0, pageSize: Int = 10): Page[ActivityWithVisualisations] = { val offset = pageSize * page DB.withConnection { implicit connection => val items = SQL( """ select * from activity left join activitytype on activity.activitytype_id = activitytype.id where user_id = {user_id} order by activity.id desc limit {pageSize} offset {offset} """).on( 'user_id -> user_id, 'pageSize -> pageSize, 'offset -> offset).as(Activity.withType2 *) ... } }
def list(page: Int) = SecuredAction { implicit request => val user = Users.getUser(request.user) val activities = Activity.listByUserId(user.id, page) Ok(views.html.activities(Some(user), activities)) }
@activities.map { case activity => <table class="table table-striped"><tbody><tr><td> <div class="row"> <div class="col-xs-4"> <p><strong>@activity.label</strong><br> <small>@activity.location</small><br> <small>@activity.activityType.name</small></p> ... </div> </div></td></tr> </tbody></table> }
"create an activity" in { val requestStr = "{...}" val request = FakeRequest(POST, "/api/0.2/livetrack/activity", requestHeader, Json.parse(requestStr)) val result = route(request).get status(result) must equalTo(OK) val resultJson = Json.parse(contentAsString(result)) resultJson.asOpt[IdResult] must beSome[IdResult]
July 2013 -> March 2014 (now)