I've got a JSON with a list of events :
[
{"id":"1","kind":"start"},
{"id":"2","kind":"start"},
{"id":"1","kind":"stop"},
{"id":"4","kind":"start"},
{"id":"4","kind":"stop"}
]
import org.scalatest.concurrent.ScalaFutures | |
import org.scalatest.{FunSpec, Matchers} | |
import scala.concurrent.{ExecutionContext, Future} | |
import scala.util.{Success, Try} | |
class Lazy[A](block: => A) { | |
private var evaluated = false | |
private lazy val underlying: A = { | |
evaluated = true |
I've got a JSON with a list of events :
[
{"id":"1","kind":"start"},
{"id":"2","kind":"start"},
{"id":"1","kind":"stop"},
{"id":"4","kind":"start"},
{"id":"4","kind":"stop"}
]
Après être passé par la SSII, le freelance et la création de startup, Loïc Knuchel est maintenant développeur Scala chez Criteo. En parallèle, il s'investit activement dans la communauté tech parisienne en participant à de nombreux meetup et conférences, aussi bien comme participant que speaker. Aller à la rencontre des autres développeurs, apprendre d'eux et partager ses expériences est crucial. C'est pourquoi il organise les HumanTalks Paris depuis plusieurs années. Côté technologies, il a commencé avec Java mais est rapidement passé à Scala en 2013 en découvrant Play Framework. Aujourd'hui, il est fan de programmation fonctionnelle et de typage fort; et cherche toujours comment écrire du code qui soit utile (à l'utilisateur) et reste le plus simple et maintenable possible, notamment via le mouvement du software craftsmanship, le DDD, l'UX, l'event storming, l'event sourcing et autres gros mots du genre ;)
Why (some) frontend devs don't like TypeScript because of types but writes React.propTypes ????
Dropdown.propTypes = {
text: React.PropTypes.object.isRequired,
children: React.PropTypes.oneOfType([
React.PropTypes.object,
React.PropTypes.array
]).isRequired,
autoClose: React.PropTypes.bool
I use Play 2.5.6 with Scala and found several interesting modules but I think some basic and really useful features are still missing...
Here is my sample app where I do my tests :
I list here needed features (according to me) from the most needed to the least needed.
En mettant en place du typage pour mes IDs, je me retrouve avec un No apply function found matching unapply parameters
quand j'utilise la macro Json.format[T]
de Play :(
Du coup je suis obligé de définir explicitement les Reads
et Writes
D'ailleurs, le type Email
ne pose pas de problème. Je pense que ça doit venir du fait que Id est générique... Mais j'ai pas trouvé comment fixer le problème.
Si quelqu'un à une idée de ce qu'il peut manquer...
Ex: User.scala, Id.scala, Email.scala et TString.scala :)
// inspired from https://github.com/stacktracejs/stacktrace.js/blob/master/stacktrace.js | |
var Log = (function(){ | |
return { | |
instrumentObj: instrumentObj | |
}; | |
// This is working on my tests, do I made some "dangerous" things ? | |
function instrumentObj(tag, obj){ | |
for(var i in obj){ | |
if(typeof obj[i] === 'function'){ |
def details(eventId: String, exponentId: String) = SecuredAction.async { implicit req => | |
withEvent(exponentId) { event => | |
withExponent(eventId) { exponent => | |
AttendeeRepository.findByUuids(exponent.info.team).map { team => | |
Ok(backend.views.html.Events.Exponents.details(exponent, team, event)) | |
} | |
} | |
} | |
} |
object Sessions extends SilhouetteEnvironment { | |
def details(eventId: String, sessionId: String) = SecuredAction.async { implicit req => | |
implicit val user = req.identity | |
val res: Future[Result] = for { | |
eventOpt: Option[Event] <- EventRepository.getByUuid(eventId) | |
sessionOpt: Option[Session] <- SessionRepository.getByUuid(sessionId) | |
} yield { | |
var res2: Option[Result] = for { | |
event: Event <- eventOpt | |
session: Session <- sessionOpt |
I'm using Play 2.3.7, Mongo 2.4.8 and reactivemongo 0.10.5 and I've got some surprising things...
When start the shell and run :
db.Exponents.aggregate([
{$match: {eventId: {$in: ["3dac7440-f8e5-497d-8b0b-77127d16e1ae", "fcb07f0c-2ff3-4408-b83e-8f42d6a00112"]}}},
{$group: {_id: "$eventId", eventCount: {$sum: 1}}}
])