Pārlūkot izejas kodu

Fix Amica day matching

Toni Fadjukoff 6 gadus atpakaļ
vecāks
revīzija
c180b79650
1 mainītis faili ar 11 papildinājumiem un 2 dzēšanām
  1. 11 2
      amica.py

+ 11 - 2
amica.py Parādīt failu

@@ -11,7 +11,11 @@ def get_restaurants(use_old, week):
11 11
     today = datetime.date.today()
12 12
     week_day = today.isocalendar()[2]
13 13
     this_monday = today - datetime.timedelta(days=week_day-1)
14
-    week_date = this_monday.strftime("%Y-%m-%d")
14
+    date_strings = []
15
+    for i in range(7):
16
+        date = this_monday + datetime.timedelta(days=i)
17
+        date_strings.append(date.strftime("%Y-%m-%d"))
18
+
15 19
     restaurants = []
16 20
     for count, info in enumerate(restaurant_info):
17 21
         title = info[0]
@@ -23,7 +27,12 @@ def get_restaurants(use_old, week):
23 27
 
24 28
         week_foods = {}
25 29
         lunch_menus = data["MenusForDays"]
26
-        for week_day, lunch_menu in enumerate(lunch_menus):
30
+        for lunch_menu in lunch_menus:
31
+            date = lunch_menu["Date"].split("T")[0]
32
+            try:
33
+                week_day = date_strings.index(date)
34
+            except:
35
+                continue
27 36
             current_day_foods = []
28 37
             set_menus = lunch_menu["SetMenus"]
29 38
             html = lunch_menu.get("Html", "")