amoeba / treestats.net

Player tracking for Asheron's Call
https://treestats.net
MIT License
8 stars 3 forks source link

Add "builds" stat that includes skills #194

Open amoeba opened 4 years ago

amoeba commented 4 years ago

I want to create a graph for builds that includes specialized skills and not just creation attributes. So I need to create a pipeline that produces a string like "100/0/100/100/0/0-melee_defense" for grouping.

I almost have it with this but not quite there because the skills aren't sorted:

[{
    $match: {
        "a": {
            "$exists": true
        }
    }
}, {
    $project: {
        sks: {
            "$objectToArray": "$sk"
        }
    }
}, {
    $project: {
        specialized: {
            "$filter": {
                input: "$sks",
                as: "skill",
                cond: {
                    "$eq": ["$$skill.v.training", "Specialized"]
                }
            }
        }
    }
}, {
    $match: {
        "specialized": {
            "$gte": ["$size", 1]
        }
    }
}, {
    $project: {
        specialized: "$specialized.k"
    }
}, {
    $project: {
        "specskillstring": {
            "$reduce": {
                input: "$specialized",
                initialValue: "",
                in: {
                    "$concat": ["$$value", "-", "$$this"]
                }
            }
        }
    }
}]
amoeba commented 4 years ago

Tried an approach that starts with $unwind and it takes too long so this isn't a good option.