clas monitoring
parent
dd45c2acb0
commit
9016719424
|
@ -89,7 +89,7 @@ final class Clas(
|
|||
def studentCreate(id: String) = SecureBody(_.Teacher) { implicit ctx => me =>
|
||||
NoTor {
|
||||
Firewall {
|
||||
WithClass(me, lila.clas.Clas.Id(id)) { _ => clas =>
|
||||
WithClass(me, lila.clas.Clas.Id(id)) { t => clas =>
|
||||
env.clas.forms.student.create
|
||||
.bindFromRequest()(ctx.body)
|
||||
.fold(
|
||||
|
@ -102,7 +102,7 @@ final class Clas(
|
|||
)
|
||||
).fuccess,
|
||||
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) =>
|
||||
Redirect(routes.Clas.studentShow(clas.id.value, user.username))
|
||||
.flashing("password" -> password.value)
|
||||
|
|
|
@ -97,11 +97,12 @@ final class ClasApi(
|
|||
def isIn(clas: Clas, userId: User.ID): Fu[Boolean] =
|
||||
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
|
||||
): Fu[(User, ClearPassword)] = {
|
||||
val email = EmailAddress(s"noreply.class.${clas.id}.$username@lichess.org")
|
||||
val password = Student.password.generate
|
||||
lila.mon.clas.studentCreate(teacher.userId)
|
||||
userRepo
|
||||
.create(
|
||||
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 {
|
||||
_ ?? ClasApi.this.invite.create(clas, user, teacher)
|
||||
}
|
||||
}
|
||||
|
||||
private[ClasApi] def join(clas: Clas, user: User): Fu[Student] = {
|
||||
val student = Student.make(user, clas, managed = false)
|
||||
|
|
|
@ -347,6 +347,10 @@ object mon {
|
|||
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 pairing {
|
||||
val batchSize = histogram("tournament.pairing.batchSize").withoutTags
|
||||
|
|
Loading…
Reference in New Issue