From a37ef637ce03e04df4de2f961d668677793eb975 Mon Sep 17 00:00:00 2001 From: zv0n Date: Sun, 27 Aug 2023 17:49:46 +0200 Subject: [PATCH] Tao: clear permanent menu before each parse --- pkg/restaurants/restaurant.go | 4 ++++ pkg/restaurants/tao.go | 1 + 2 files changed, 5 insertions(+) diff --git a/pkg/restaurants/restaurant.go b/pkg/restaurants/restaurant.go index d46de68..7f3e577 100644 --- a/pkg/restaurants/restaurant.go +++ b/pkg/restaurants/restaurant.go @@ -55,6 +55,10 @@ func (restaurant *Restaurant) clearMenus() { } } +func (restaurant *Restaurant) clearPermanentMenus() { + restaurant.permanent = []Meal{} +} + func (restaurant *Restaurant) MarshalJSON() ([]byte, error) { return json.Marshal(&RestaurantJSON{ Id: restaurant.id, diff --git a/pkg/restaurants/tao.go b/pkg/restaurants/tao.go index 14154ba..fd9c0af 100644 --- a/pkg/restaurants/tao.go +++ b/pkg/restaurants/tao.go @@ -24,6 +24,7 @@ func NewTaoRestaurant(url string, name string, id int) *TaoRestaurant { func (restaurant *TaoRestaurant) Parse() { restaurant.clearMenus() + restaurant.clearPermanentMenus() resp, err := http.Get(restaurant.url) if err != nil { return