File tree 2 files changed +15
-1
lines changed
2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,10 @@ extension Meal {
13
13
func matches( meal: Meal ) -> Bool {
14
14
return link. contains ( String ( meal. id) )
15
15
}
16
+
17
+ var isSoldOut : Bool {
18
+ title. lowercased ( ) . contains ( " ausverkauft " )
19
+ }
16
20
}
17
21
18
22
public static func rssData( session: URLSession = . shared) async throws -> [ RSSMeal ] {
Original file line number Diff line number Diff line change @@ -37,7 +37,17 @@ extension Meal {
37
37
let ( data, _) = try await session. data ( from: URL . Mensa. meals ( canteen: canteen, date: date) )
38
38
let meals = try JSONDecoder ( ) . decode ( [ Meal ] . self, from: data)
39
39
Logger . emealKit. debug ( " Successfully fetched \( meals. count) meals " )
40
- return meals
40
+
41
+ let feedItems = try await Self . rssData ( )
42
+ return meals. map { meal in
43
+ var meal = meal
44
+ let matchingItem = feedItems. first { $0. matches ( meal: meal) }
45
+ if let matchingItem {
46
+ Logger . emealKit. debug ( " Found matching feeditem for \( meal. id) " )
47
+ meal. isSoldOut = matchingItem. isSoldOut
48
+ }
49
+ return meal
50
+ }
41
51
} catch ( let error) {
42
52
Logger . emealKit. error ( " Failed to fetch meal data: \( String ( describing: error) ) " )
43
53
throw . other( error)
You can’t perform that action at this time.
0 commit comments