Skip to content

Commit

Permalink
Small cosmetics fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
CorentinB authored and noqqe committed May 22, 2023
1 parent 73e982a commit f0fc422
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
18 changes: 8 additions & 10 deletions src/serra/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,19 @@ func modifyCardCount(coll *Collection, c *Card, amount int64, foil bool) error {
return nil
}

func findCardbyCollectornumber(coll *Collection, setcode string, collectornumber string) (*Card, error) {

func findCardByCollectorNumber(coll *Collection, setCode string, collectorNumber string) (*Card, error) {
sort := bson.D{{"_id", 1}}
search_filter := bson.D{{"set", setcode}, {"collectornumber", collectornumber}}
stored_cards, err := coll.storageFind(search_filter, sort)
searchFilter := bson.D{{"set", setCode}, {"collectornumber", collectorNumber}}
storedCards, err := coll.storageFind(searchFilter, sort)
if err != nil {
return &Card{}, err
}

if len(stored_cards) < 1 {
if len(storedCards) < 1 {
return &Card{}, errors.New("Card not found")
}

return &stored_cards[0], nil
return &storedCards[0], nil
}

func stringToTime(s primitive.DateTime) string {
Expand All @@ -93,17 +92,16 @@ func missing(a, b []string) []string {
}

func findSetByCode(coll *Collection, setcode string) (*Set, error) {

stored_sets, err := coll.storageFindSet(bson.D{{"code", setcode}}, bson.D{{"_id", 1}})
storedSets, err := coll.storageFindSet(bson.D{{"code", setcode}}, bson.D{{"_id", 1}})
if err != nil {
return &Set{}, err
}

if len(stored_sets) < 1 {
if len(storedSets) < 1 {
return &Set{}, errors.New("Set not found")
}

return &stored_sets[0], nil
return &storedSets[0], nil
}

func convertManaSymbols(sym []interface{}) string {
Expand Down
2 changes: 1 addition & 1 deletion src/serra/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func removeCards(cards []string, count int64) error {
setName := strings.Split(card, "/")[0]

// Fetch card from scryfall
c, err := findCardbyCollectornumber(coll, setName, collectorNumber)
c, err := findCardByCollectorNumber(coll, setName, collectorNumber)
if err != nil {
LogMessage(fmt.Sprintf("%v", err), "red")
continue
Expand Down

0 comments on commit f0fc422

Please sign in to comment.