From 0260f772fcaf627d4b4c3611b46a8db02cb76f8b Mon Sep 17 00:00:00 2001 From: horus Date: Sat, 17 Feb 2018 16:08:56 +0100 Subject: Checks for correct abv per spirit type. (crawler) --- crawler/sanitize.go | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'crawler/sanitize.go') diff --git a/crawler/sanitize.go b/crawler/sanitize.go index 3d61c46..8d84507 100644 --- a/crawler/sanitize.go +++ b/crawler/sanitize.go @@ -14,8 +14,7 @@ func sanitize_offer(angebote []Angebot, shop Shop) []Angebot { for _, offer := range angebote { offer.Name = sanitize_name(offer.Name) - if offer.Abv == 0 { - WarnOffer(offer, "Sanitizer: Abv is zero") + if false == _check_abv_for_spirit_type(offer) { continue } if offer.Volume == 0 { @@ -157,3 +156,29 @@ func sanitize_base_price(price_noisy string) (price int, err error) { return convert_price(price_noisy) } + +func _check_abv_for_spirit_type(offer Angebot) bool { + + if offer.Abv < 40 && (offer.Spirit_type == "Whisky" || offer.Spirit_type == "Cognac") { + WarnOffer(offer, "Sanitizer: Abv below 40% for "+offer.Spirit_type) + return false + } + + if offer.Abv < 37.5 && (offer.Spirit_type == "Rum" || offer.Spirit_type == "Gin" || offer.Spirit_type == "Wodka" || offer.Spirit_type == "Grappa") { + WarnOffer(offer, "Sanitizer: Abv below 37,5% for "+offer.Spirit_type) + return false + } + + if offer.Abv < 14 && offer.Spirit_type == "Likör" { + WarnOffer(offer, "Sanitizer: Abv below 14% for "+offer.Spirit_type) + return false + + } + + if offer.Abv == 0 { + WarnOffer(offer, "Sanitizer: Abv is zero") + return false + } + + return true +} -- cgit v1.2.3