added Raising Cards
This commit is contained in:
parent
17be721c3b
commit
c8279d6ead
@ -43,6 +43,10 @@ Calculate value of all sets
|
|||||||
|
|
||||||
db.sets.aggregate({$match: {serra_prices: {$exists: true}}}, {$project: {name: 1, "totalValue": {$arrayElemAt: ["$serra_prices", -1]} }}, {$group: {_id: null, total: {$sum: "$totalValue.value" }}})
|
db.sets.aggregate({$match: {serra_prices: {$exists: true}}}, {$project: {name: 1, "totalValue": {$arrayElemAt: ["$serra_prices", -1]} }}, {$group: {_id: null, total: {$sum: "$totalValue.value" }}})
|
||||||
|
|
||||||
|
Calculate what cards gained most value in percent
|
||||||
|
|
||||||
|
db.cards.aggregate({$project: {set: 1, collectornumber:1, name: 1, "old": {$arrayElemAt: ["$serra_prices.value", -2]}, "current": {$arrayElemAt: ["$serra_prices.value", -1]} }}, {$match: {old: {$gt: 2}}} ,{$project: {name: 1,set:1,collectornumber:1,current:1, "rate": {$subtract: [{$divide: ["$current", {$divide: ["$old", 100]}]}, 100]} }}, {$sort: { rate: -1}})
|
||||||
|
|
||||||
# MongoDB Operations
|
# MongoDB Operations
|
||||||
|
|
||||||
Do a database dump
|
Do a database dump
|
||||||
|
|||||||
5
serra.go
5
serra.go
@ -19,12 +19,14 @@ var opts struct {
|
|||||||
Sets bool `docopt:"sets"`
|
Sets bool `docopt:"sets"`
|
||||||
Stats bool `docopt:"stats"`
|
Stats bool `docopt:"stats"`
|
||||||
Missing bool `docopt:"missing"`
|
Missing bool `docopt:"missing"`
|
||||||
|
Raising bool `docopt:"raising"`
|
||||||
Update bool `docopt:"update"`
|
Update bool `docopt:"update"`
|
||||||
CardId []string `docopt:"<cardid>"`
|
CardId []string `docopt:"<cardid>"`
|
||||||
SetCode string `docopt:"<setcode>,--set"`
|
SetCode string `docopt:"<setcode>,--set"`
|
||||||
Count int64 `docopt:"--count"`
|
Count int64 `docopt:"--count"`
|
||||||
Sort string `docopt:"--sort"`
|
Sort string `docopt:"--sort"`
|
||||||
Rarity string `docopt:"--rarity"`
|
Rarity string `docopt:"--rarity"`
|
||||||
|
Limit float64 `docopt:"--limit"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Main Loop
|
// Main Loop
|
||||||
@ -37,6 +39,7 @@ Usage:
|
|||||||
serra remove <cardid>...
|
serra remove <cardid>...
|
||||||
serra cards [--rarity=<rarity>] [--set=<setcode>] [--sort=<sort>]
|
serra cards [--rarity=<rarity>] [--set=<setcode>] [--sort=<sort>]
|
||||||
serra card <cardid>...
|
serra card <cardid>...
|
||||||
|
serra raising [--limit=<limit>]
|
||||||
serra missing <setcode>
|
serra missing <setcode>
|
||||||
serra set <setcode>
|
serra set <setcode>
|
||||||
serra sets
|
serra sets
|
||||||
@ -68,6 +71,8 @@ Options:
|
|||||||
serra.Sets()
|
serra.Sets()
|
||||||
} else if opts.Missing {
|
} else if opts.Missing {
|
||||||
serra.Missing(opts.SetCode)
|
serra.Missing(opts.SetCode)
|
||||||
|
} else if opts.Raising {
|
||||||
|
serra.Raising(opts.Limit)
|
||||||
} else if opts.Set {
|
} else if opts.Set {
|
||||||
serra.ShowSet(opts.SetCode)
|
serra.ShowSet(opts.SetCode)
|
||||||
} else if opts.Update {
|
} else if opts.Update {
|
||||||
|
|||||||
@ -398,6 +398,69 @@ func Update() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Raising(limit float64) error {
|
||||||
|
|
||||||
|
client := storage_connect()
|
||||||
|
coll := &Collection{client.Database("serra").Collection("cards")}
|
||||||
|
defer storage_disconnect(client)
|
||||||
|
|
||||||
|
// db.cards.aggregate({$project: {set: 1, collectornumber:1, name: 1, "old": {$arrayElemAt: ["$serra_prices.value", -2]}, "current": {$arrayElemAt: ["$serra_prices.value", -1]} }}, {$match: {old: {$gt: 2}}} ,{$project: {name: 1,set:1,collectornumber:1,current:1, "rate": {$subtract: [{$divide: ["$current", {$divide: ["$old", 100]}]}, 100]} }}, {$sort: { rate: -1}})
|
||||||
|
raise_pipeline := mongo.Pipeline{
|
||||||
|
bson.D{{"$project",
|
||||||
|
bson.D{
|
||||||
|
{"name", true},
|
||||||
|
{"set", true},
|
||||||
|
{"collectornumber", true},
|
||||||
|
{"old",
|
||||||
|
bson.D{{"$arrayElemAt",
|
||||||
|
bson.A{"$serra_prices.value", -2},
|
||||||
|
}},
|
||||||
|
},
|
||||||
|
{"current",
|
||||||
|
bson.D{{"$arrayElemAt",
|
||||||
|
bson.A{"$serra_prices.value", -1},
|
||||||
|
}},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}},
|
||||||
|
bson.D{{"$match",
|
||||||
|
bson.D{{"old", bson.D{{"$gt", limit}}}},
|
||||||
|
}},
|
||||||
|
bson.D{{"$project",
|
||||||
|
bson.D{
|
||||||
|
{"name", true},
|
||||||
|
{"set", true},
|
||||||
|
{"old", true},
|
||||||
|
{"current", true},
|
||||||
|
{"collectornumber", true},
|
||||||
|
{"rate",
|
||||||
|
bson.D{{"$subtract",
|
||||||
|
bson.A{
|
||||||
|
bson.D{{"$divide",
|
||||||
|
bson.A{"$current",
|
||||||
|
bson.D{{"$divide",
|
||||||
|
bson.A{"$old", 100},
|
||||||
|
}},
|
||||||
|
},
|
||||||
|
}},
|
||||||
|
100,
|
||||||
|
},
|
||||||
|
}},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}},
|
||||||
|
bson.D{{"$sort",
|
||||||
|
bson.D{{"rate", -1}}}},
|
||||||
|
bson.D{{"$limit", 20}},
|
||||||
|
}
|
||||||
|
raise, _ := coll.storage_aggregate(raise_pipeline)
|
||||||
|
for _, e := range raise {
|
||||||
|
fmt.Printf("%s+%.0f%%%s %s%s%s (%s/%s) (%.2f->%s%.2f EUR%s) \n", Green, e["rate"], Reset, Yellow, e["name"], Reset, e["set"], e["collectornumber"], e["old"], Green, e["current"], Reset)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
func Stats() {
|
func Stats() {
|
||||||
|
|
||||||
client := storage_connect()
|
client := storage_connect()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user