clas monitoring
This commit is contained in:
parent
dd45c2acb0
commit
9016719424
|
@ -89,7 +89,7 @@ final class Clas(
|
||||||
def studentCreate(id: String) = SecureBody(_.Teacher) { implicit ctx => me =>
|
def studentCreate(id: String) = SecureBody(_.Teacher) { implicit ctx => me =>
|
||||||
NoTor {
|
NoTor {
|
||||||
Firewall {
|
Firewall {
|
||||||
WithClass(me, lila.clas.Clas.Id(id)) { _ => clas =>
|
WithClass(me, lila.clas.Clas.Id(id)) { t => clas =>
|
||||||
env.clas.forms.student.create
|
env.clas.forms.student.create
|
||||||
.bindFromRequest()(ctx.body)
|
.bindFromRequest()(ctx.body)
|
||||||
.fold(
|
.fold(
|
||||||
|
@ -102,7 +102,7 @@ final class Clas(
|
||||||
)
|
)
|
||||||
).fuccess,
|
).fuccess,
|
||||||
username =>
|
username =>
|
||||||
env.clas.api.student.create(clas, username)(env.user.authenticator.passEnc) map {
|
env.clas.api.student.create(clas, username, t.teacher)(env.user.authenticator.passEnc) map {
|
||||||
case (user, password) =>
|
case (user, password) =>
|
||||||
Redirect(routes.Clas.studentShow(clas.id.value, user.username))
|
Redirect(routes.Clas.studentShow(clas.id.value, user.username))
|
||||||
.flashing("password" -> password.value)
|
.flashing("password" -> password.value)
|
||||||
|
|
|
@ -97,11 +97,12 @@ final class ClasApi(
|
||||||
def isIn(clas: Clas, userId: User.ID): Fu[Boolean] =
|
def isIn(clas: Clas, userId: User.ID): Fu[Boolean] =
|
||||||
coll.exists($id(Student.id(userId, clas.id)))
|
coll.exists($id(Student.id(userId, clas.id)))
|
||||||
|
|
||||||
def create(clas: Clas, username: String)(
|
def create(clas: Clas, username: String, teacher: Teacher)(
|
||||||
hashPassword: ClearPassword => HashedPassword
|
hashPassword: ClearPassword => HashedPassword
|
||||||
): Fu[(User, ClearPassword)] = {
|
): Fu[(User, ClearPassword)] = {
|
||||||
val email = EmailAddress(s"noreply.class.${clas.id}.$username@lichess.org")
|
val email = EmailAddress(s"noreply.class.${clas.id}.$username@lichess.org")
|
||||||
val password = Student.password.generate
|
val password = Student.password.generate
|
||||||
|
lila.mon.clas.studentCreate(teacher.userId)
|
||||||
userRepo
|
userRepo
|
||||||
.create(
|
.create(
|
||||||
username = username,
|
username = username,
|
||||||
|
@ -118,10 +119,12 @@ final class ClasApi(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def invite(clas: Clas, user: User, teacher: Teacher.WithUser): Funit =
|
def invite(clas: Clas, user: User, teacher: Teacher.WithUser): Funit = {
|
||||||
|
lila.mon.clas.studentInvite(teacher.user.id)
|
||||||
!isIn(clas, user.id) flatMap {
|
!isIn(clas, user.id) flatMap {
|
||||||
_ ?? ClasApi.this.invite.create(clas, user, teacher)
|
_ ?? ClasApi.this.invite.create(clas, user, teacher)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private[ClasApi] def join(clas: Clas, user: User): Fu[Student] = {
|
private[ClasApi] def join(clas: Clas, user: User): Fu[Student] = {
|
||||||
val student = Student.make(user, clas, managed = false)
|
val student = Student.make(user, clas, managed = false)
|
||||||
|
|
|
@ -347,6 +347,10 @@ object mon {
|
||||||
def profile(coachId: String) = counter("coach.pageView").withTag("name", coachId)
|
def profile(coachId: String) = counter("coach.pageView").withTag("name", coachId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
object clas {
|
||||||
|
def studentCreate(teacher: String) = counter("clas.student.create").withTag("teacher", teacher)
|
||||||
|
def studentInvite(teacher: String) = counter("clas.student.invite").withTag("teacher", teacher)
|
||||||
|
}
|
||||||
object tournament {
|
object tournament {
|
||||||
object pairing {
|
object pairing {
|
||||||
val batchSize = histogram("tournament.pairing.batchSize").withoutTags
|
val batchSize = histogram("tournament.pairing.batchSize").withoutTags
|
||||||
|
|
Loading…
Reference in a new issue