stats
This commit is contained in:
parent
f5b0850ab7
commit
c002fbafce
@ -39,6 +39,10 @@ Set value
|
||||
|
||||
db.cards.aggregate([{ $group: { _id: { set: "$set" }, value: { $sum: { $multiply: ["$prices.eur", "$serra_count"] } }, count: { $sum: 1 } } }])
|
||||
|
||||
Color distribution
|
||||
|
||||
db.cards.aggregate([{ $group: { _id: { color: "$colors" }, count: { $sum: 1 } } }])
|
||||
|
||||
|
||||
# MongoDB Operations
|
||||
|
||||
|
||||
3
serra.go
3
serra.go
@ -17,6 +17,7 @@ Usage:
|
||||
serra set <set>
|
||||
serra sets
|
||||
serra update
|
||||
serra stats
|
||||
|
||||
Options:
|
||||
-h --help Show this screen.
|
||||
@ -35,6 +36,8 @@ Options:
|
||||
serra.ShowSet(args["<set>"].(string))
|
||||
} else if args["update"].(bool) {
|
||||
serra.Update()
|
||||
} else if args["stats"].(bool) {
|
||||
serra.Stats()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -145,3 +145,24 @@ func Update() {
|
||||
|
||||
storage_disconnect(client)
|
||||
}
|
||||
|
||||
func Stats() {
|
||||
LogMessage(fmt.Sprintf("Serra %v\n", version), "green")
|
||||
|
||||
LogMessage(fmt.Sprintf("Color distribution in Collection"), "green")
|
||||
client := storage_connect()
|
||||
coll := &Collection{client.Database("serra").Collection("cards")}
|
||||
|
||||
groupStage := bson.D{
|
||||
{"$group", bson.D{
|
||||
{"_id", "$coloridentity"},
|
||||
{"count", bson.D{{"$sum", 1}}},
|
||||
}}}
|
||||
|
||||
sets, _ := coll.storage_aggregate(groupStage)
|
||||
for _, set := range sets {
|
||||
|
||||
// TODO fix primitiveA Problem with loop and reflect
|
||||
fmt.Printf("* %s %d\n", set["_id"], set["count"])
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user