import { ApiCall } from "tsrpc";
import { ReqGroupRank, ResGroupRank } from "../../cross/protocols/kbzz/PtlGroupRank";

export default async function (call: ApiCall<ReqGroupRank, ResGroupRank>) {
    // TODO
    let db = await G.mongodb.collection('kbzzGroupTroop').find({ group: call.req.group }).toArray();

    call.succ({
        rank: db.map(d => {
            return {
                troop: d.troop,
                score: d.score
            };
        }),
        log: (await G.mongodb.collection('kbzzGroupLog').findOne({ group: call.req.group }))?.log || []
    });
}