Compare commits

...

2 Commits

Author SHA1 Message Date
a37ef637ce Tao: clear permanent menu before each parse
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2023-08-27 17:49:46 +02:00
a270bf12ff Restaurant: fix JSON marshalling 2023-08-27 17:49:30 +02:00
2 changed files with 6 additions and 0 deletions

View File

@ -55,6 +55,10 @@ func (restaurant *Restaurant) clearMenus() {
} }
} }
func (restaurant *Restaurant) clearPermanentMenus() {
restaurant.permanent = []Meal{}
}
func (restaurant *Restaurant) MarshalJSON() ([]byte, error) { func (restaurant *Restaurant) MarshalJSON() ([]byte, error) {
return json.Marshal(&RestaurantJSON{ return json.Marshal(&RestaurantJSON{
Id: restaurant.id, Id: restaurant.id,
@ -66,6 +70,7 @@ func (restaurant *Restaurant) MarshalJSON() ([]byte, error) {
func (restaurant *Restaurant) GetSpecificDayObject(days []int) RestaurantJSON { func (restaurant *Restaurant) GetSpecificDayObject(days []int) RestaurantJSON {
obj := RestaurantJSON{ obj := RestaurantJSON{
Id: restaurant.id,
Restaurant: restaurant.name, Restaurant: restaurant.name,
PermanentMeals: restaurant.permanent, PermanentMeals: restaurant.permanent,
} }

View File

@ -24,6 +24,7 @@ func NewTaoRestaurant(url string, name string, id int) *TaoRestaurant {
func (restaurant *TaoRestaurant) Parse() { func (restaurant *TaoRestaurant) Parse() {
restaurant.clearMenus() restaurant.clearMenus()
restaurant.clearPermanentMenus()
resp, err := http.Get(restaurant.url) resp, err := http.Get(restaurant.url)
if err != nil { if err != nil {
return return