Add locate functonality

This commit is contained in:
The Magician 2024-09-12 13:31:42 +01:00
parent a18c9b2101
commit 10b3e1e46f
2 changed files with 14 additions and 3 deletions

View File

@ -34,10 +34,21 @@ func LocateCards(db *sql.DB, cardNames []string, criteria SearchCriteria) ([]str
if err != nil { if err != nil {
return locations, err return locations, err
} }
// TODO: Filter by search criteria
var location string var location string
for _, result := range results { for _, result := range results {
printing := database.CardPrinting{
SetCode: result.SetCode,
IsFoil: result.IsFoil,
IsPromo: result.IsPromo,
Language: result.Language,
}
filter := filterPrinting(printing, criteria)
if filter {
continue
}
location = fmt.Sprintf("%s (%s %s) [%s]", location = fmt.Sprintf("%s (%s %s) [%s]",
result.CardName, result.CardName,
result.SetCode, result.SetCode,

View File

@ -4,7 +4,7 @@ import "testing"
func Test_GetBinderLocationDescription_ReturnsCorrectFormat_ForFrontSlots(t *testing.T) { func Test_GetBinderLocationDescription_ReturnsCorrectFormat_ForFrontSlots(t *testing.T) {
var position int = 24 var position int = 24
var expected string = "on page 2 in front slot 6" var expected string = " on page 2 in front slot 6"
description := GetBinderLocationDescription(position) description := GetBinderLocationDescription(position)
@ -15,7 +15,7 @@ func Test_GetBinderLocationDescription_ReturnsCorrectFormat_ForFrontSlots(t *tes
func Test_GetBinderLocationDescription_ReturnsCorrectFormat_ForBackSlots(t *testing.T) { func Test_GetBinderLocationDescription_ReturnsCorrectFormat_ForBackSlots(t *testing.T) {
var position int = 17 var position int = 17
var expected string = "on page 1 in back slot 8" var expected string = " on page 1 in back slot 8"
description := GetBinderLocationDescription(position) description := GetBinderLocationDescription(position)