fund
This commit is contained in:
@ -63,6 +63,8 @@ export type Work = Rec & Re & ({
|
||||
export type Fund = Rec & {
|
||||
fund: number,
|
||||
msg: string,
|
||||
rd?: Dst["_id"]["rd"],
|
||||
unit?: number,
|
||||
}
|
||||
|
||||
export type Dst = {
|
||||
@ -81,6 +83,8 @@ export type Act = {
|
||||
act: "fund",
|
||||
aid: Agd["_id"],
|
||||
msg: string,
|
||||
rd?: Dst["_id"]["rd"],
|
||||
unit?: number,
|
||||
} | {
|
||||
act: "nbr",
|
||||
uid: number,
|
||||
|
@ -123,7 +123,11 @@ export async function pre_fund(
|
||||
if (!a || a.act !== "fund") return null
|
||||
const utc = Date.now()
|
||||
await act_u(actid, { $set: { exp: utc } })
|
||||
return rec_c(coll.fund, { _id: { uid: pas.uid, aid: a.aid, utc }, fund: 0, msg: a.msg })
|
||||
return rec_c(coll.fund, {
|
||||
_id: { uid: pas.uid, aid: a.aid, utc }, fund: 0, msg: a.msg,
|
||||
...a.rd ? { rd: a.rd } : {},
|
||||
...a.unit ? { unit: a.unit } : {},
|
||||
})
|
||||
}
|
||||
|
||||
export async function pre_dst(
|
||||
|
@ -133,7 +133,7 @@ Deno.test("rec", async () => {
|
||||
utce: utc + 2 * utc_h,
|
||||
})
|
||||
assertEquals(id, await Promise.all(id.map(_id => rec_c(coll.fund, {
|
||||
_id, fund: 32, msg: "msg"
|
||||
_id, fund: 32, msg: "msg", rd: 1, unit: 3,
|
||||
}))))
|
||||
assertEquals(await nrec(), { work: 5, fund: 3 })
|
||||
assertEquals(await nrec({ uid: [2] }), { work: 2, fund: 2 })
|
||||
|
Reference in New Issue
Block a user