diff --git a/cardsinfo/scgprices.go b/cardsinfo/scgprices.go index a07e88c..f4ad1c4 100644 --- a/cardsinfo/scgprices.go +++ b/cardsinfo/scgprices.go @@ -11,6 +11,7 @@ import ( const Scgurl = "https://www.starcitygames.com/search.php?search_query=" const Scgapi = "https://newstarcityconnector.herokuapp.com/eyApi/products/" +const MaxCards = 4 func GetSCGPrices(name string) ([]CardPrice, error) { preprocessedName := preprocessNameForSearch(name) @@ -27,7 +28,7 @@ func preprocessNameForSearch(name string) string { } func fetchPrices(doc *html.Node) ([]CardPrice, error) { - priceContainers := getPriceContainers(doc) + priceContainers := getPriceContainers(doc)[:MaxCards] length := len(priceContainers) prices := make(chan CardPrice, length) finished := make(chan bool, length) diff --git a/vk/handlers.go b/vk/handlers.go index c80ac4d..4b4ec74 100644 --- a/vk/handlers.go +++ b/vk/handlers.go @@ -12,15 +12,6 @@ import ( "github.com/gin-gonic/gin" ) -const Cardslimit = 8 - -func min(a, b int) int { - if a < b { - return a - } - return b -} - func HandleMessage(c *gin.Context) { var req MessageRequest _ = c.BindJSON(&req) @@ -57,8 +48,6 @@ func handleSearch(req *MessageRequest) { log.Printf("[error] Could not find SCG prices. Message: %s card name: %s", err.Error(), cardName) return } - elements := min(Cardslimit, len(prices)) - prices = prices[:elements] priceInfo := cardsinfo.FormatCardPrices(cardName, prices) Message(req.Object.UserId, priceInfo) }