Fix Delverlens import flow
This commit is contained in:
parent
73dc06d78f
commit
0e3ee54e1c
|
@ -6,6 +6,7 @@ import (
|
|||
)
|
||||
|
||||
var ErrStorageAreaDoesNotExist error = errors.New("Storage area does not exist.")
|
||||
var ErrNoEmptySlotsInBinder error = errors.New("No empty slots in binder.")
|
||||
|
||||
var StorageAreaTypeBinder string = "Binder"
|
||||
var StorageAreaTypeBox string = "Box"
|
||||
|
@ -75,7 +76,7 @@ func GetNextEmptySlotInBinder(db *sql.DB, storageAreaId int) (int, error) {
|
|||
var emptySlotId int
|
||||
err := db.QueryRow(query, storageAreaId).Scan(&emptySlotId)
|
||||
if err == sql.ErrNoRows {
|
||||
return -1, nil
|
||||
return -1, ErrNoEmptySlotsInBinder
|
||||
} else if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
|
|
@ -10,9 +10,9 @@ func ImportDelverLensCards(db *sql.DB, cards []delverlens.DelverLensCard, storag
|
|||
for _, card := range cards {
|
||||
var cardPrintingId string
|
||||
if card.IsFoil {
|
||||
cardPrintingId = card.ScryfallID + "n"
|
||||
} else {
|
||||
cardPrintingId = card.ScryfallID + "f"
|
||||
} else {
|
||||
cardPrintingId = card.ScryfallID + "n"
|
||||
}
|
||||
|
||||
cardLocation := database.CardLocation{
|
||||
|
|
|
@ -94,7 +94,7 @@ func StoreCard(db *sql.DB, cardLocation database.CardLocation) error {
|
|||
if storageAreaType == database.StorageAreaTypeBinder {
|
||||
nextEmptySlotId, err := database.GetNextEmptySlotInBinder(db, cardLocation.StorageAreaId)
|
||||
|
||||
if err == sql.ErrNoRows {
|
||||
if err == database.ErrNoEmptySlotsInBinder {
|
||||
err = storeAfterLastCard(db, cardLocation)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
Loading…
Reference in New Issue