summaryrefslogtreecommitdiff
path: root/crawler
diff options
context:
space:
mode:
authorhorus2018-02-17 16:08:56 +0100
committerhorus2018-02-17 16:08:56 +0100
commit0260f772fcaf627d4b4c3611b46a8db02cb76f8b (patch)
tree387c1ca563b97188a4cabe9eb1571b77cc047cb6 /crawler
parentdfe52cc605ae3e78d57da8c9e1d08e7f73a67859 (diff)
downloadalkobote-0260f772fcaf627d4b4c3611b46a8db02cb76f8b.tar.gz
Checks for correct abv per spirit type. (crawler)
Diffstat (limited to 'crawler')
-rw-r--r--crawler/sanitize.go29
1 files changed, 27 insertions, 2 deletions
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
+}