From 10b3e1e46f5356b5ffd0f84dd398d17c8c9802e0 Mon Sep 17 00:00:00 2001 From: The Magician Date: Thu, 12 Sep 2024 13:31:42 +0100 Subject: [PATCH] Add locate functonality --- sevenkeys/logic/locate.go | 13 ++++++++++++- sevenkeys/logic/locate_test.go | 4 ++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/sevenkeys/logic/locate.go b/sevenkeys/logic/locate.go index bf9fc31..c71880e 100644 --- a/sevenkeys/logic/locate.go +++ b/sevenkeys/logic/locate.go @@ -34,10 +34,21 @@ func LocateCards(db *sql.DB, cardNames []string, criteria SearchCriteria) ([]str if err != nil { return locations, err } - // TODO: Filter by search criteria var location string 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]", result.CardName, result.SetCode, diff --git a/sevenkeys/logic/locate_test.go b/sevenkeys/logic/locate_test.go index cd27632..baf4ef5 100644 --- a/sevenkeys/logic/locate_test.go +++ b/sevenkeys/logic/locate_test.go @@ -4,7 +4,7 @@ import "testing" func Test_GetBinderLocationDescription_ReturnsCorrectFormat_ForFrontSlots(t *testing.T) { 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) @@ -15,7 +15,7 @@ func Test_GetBinderLocationDescription_ReturnsCorrectFormat_ForFrontSlots(t *tes func Test_GetBinderLocationDescription_ReturnsCorrectFormat_ForBackSlots(t *testing.T) { 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)