list gifted patrons
parent
c68147517e
commit
05e60f3e00
|
@ -382,7 +382,7 @@ final class User(
|
|||
appeal <- isGranted(_.Appeals) ?? env.appeal.api.get(user)
|
||||
} yield view.modLog(history, appeal)
|
||||
|
||||
val plan = isGranted(_.Admin) ?? env.plan.api.recentChargesOf(user).map(view.plan).dmap(~_)
|
||||
val plan = isGranted(_.Admin) ?? env.plan.api.recentChargesOf(user).map(view.plan(user)).dmap(~_)
|
||||
|
||||
val student = env.clas.api.student.findManaged(user).map2(view.student).dmap(~_)
|
||||
|
||||
|
|
|
@ -249,7 +249,7 @@ object mod {
|
|||
span(cls := "text inline")(rageSit.counterView)
|
||||
)
|
||||
|
||||
def plan(charges: List[lila.plan.Charge])(implicit ctx: Context): Option[Frag] =
|
||||
def plan(u: User)(charges: List[lila.plan.Charge])(implicit ctx: Context): Option[Frag] =
|
||||
charges.headOption.map { firstCharge =>
|
||||
mzSection("plan")(
|
||||
strong(cls := "text", dataIcon := patronIconChar)(
|
||||
|
@ -267,7 +267,19 @@ object mod {
|
|||
),
|
||||
ul(
|
||||
charges.map { c =>
|
||||
li(c.money.display, " with ", c.serviceName, " on ", showDateTimeUTC(c.date), " UTC")
|
||||
li(
|
||||
c.money.display,
|
||||
c.giftTo match {
|
||||
case Some(giftedId) if u is giftedId => frag(" Gift from", userIdLink(c.userId))
|
||||
case Some(giftedId) => frag(" Gift to", userIdLink(giftedId.some))
|
||||
case _ => emptyFrag
|
||||
},
|
||||
" with ",
|
||||
c.serviceName,
|
||||
" on ",
|
||||
showDateTimeUTC(c.date),
|
||||
" UTC"
|
||||
)
|
||||
}
|
||||
),
|
||||
br
|
||||
|
|
|
@ -350,7 +350,16 @@ final class PlanApi(
|
|||
def recentChargeUserIds: Fu[List[User.ID]] = recentChargeUserIdsCache.getUnit
|
||||
|
||||
def recentChargesOf(user: User): Fu[List[Charge]] =
|
||||
chargeColl.find($doc("userId" -> user.id)).sort($doc("date" -> -1)).cursor[Charge]().list()
|
||||
chargeColl
|
||||
.find(
|
||||
$or(
|
||||
$doc("userId" -> user.id),
|
||||
$doc("giftTo" -> user.id)
|
||||
)
|
||||
)
|
||||
.sort($doc("date" -> -1))
|
||||
.cursor[Charge]()
|
||||
.list()
|
||||
|
||||
private val topPatronUserIdsNb = 300
|
||||
private val topPatronUserIdsCache = mongoCache.unit[List[User.ID]](
|
||||
|
|
Loading…
Reference in New Issue