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 } } }])
|
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
|
# MongoDB Operations
|
||||||
|
|
||||||
|
|||||||
3
serra.go
3
serra.go
@ -17,6 +17,7 @@ Usage:
|
|||||||
serra set <set>
|
serra set <set>
|
||||||
serra sets
|
serra sets
|
||||||
serra update
|
serra update
|
||||||
|
serra stats
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-h --help Show this screen.
|
-h --help Show this screen.
|
||||||
@ -35,6 +36,8 @@ Options:
|
|||||||
serra.ShowSet(args["<set>"].(string))
|
serra.ShowSet(args["<set>"].(string))
|
||||||
} else if args["update"].(bool) {
|
} else if args["update"].(bool) {
|
||||||
serra.Update()
|
serra.Update()
|
||||||
|
} else if args["stats"].(bool) {
|
||||||
|
serra.Stats()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -145,3 +145,24 @@ func Update() {
|
|||||||
|
|
||||||
storage_disconnect(client)
|
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