Skip to content

Commit 9395d64

Browse files
committed
fix: Buffet new layout
1 parent 54dfe45 commit 9395d64

6 files changed

Lines changed: 695 additions & 1795 deletions

File tree

api/buffet/src/commonMain/kotlin/cz/lastaapps/api/buffet/api/BuffetScraper.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2025, Petr Laštovička as Lasta apps, All rights reserved
2+
* Copyright 2026, Petr Laštovička as Lasta apps, All rights reserved
33
*
44
* This file is part of Menza.
55
*
@@ -69,7 +69,7 @@ internal class BuffetScraperImpl : BuffetScraper {
6969
// Split buffets
7070
// fs, fel
7171
private val splitMainRegex =
72-
"""(.*)</td>\s*<td(.*)"""
72+
"""(.*)</div>\s*<div(.*)"""
7373
.toRegex(regexOptions)
7474

7575
// Matches days

api/buffet/src/jvmTest/kotlin/cz/lastaapps/api/buffet/test/BuffetScraperTest.kt

Lines changed: 23 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2025, Petr Laštovička as Lasta apps, All rights reserved
2+
* Copyright 2026, Petr Laštovička as Lasta apps, All rights reserved
33
*
44
* This file is part of Menza.
55
*
@@ -71,45 +71,9 @@ class BuffetScraperTest :
7171
}
7272
}
7373

74-
"Scrape 2025-01-06" {
75-
val log = Logger.withTag("2025-01-06")
76-
val html = loadPage("2025-01-06.html")
77-
val scraper = scraper()
78-
val date = scraper.matchValidity(html)
79-
val content = scraper.matchContent(html)
80-
81-
log.i { date.toString() }
82-
log.i { content.toString() }
83-
84-
dateRangeTest(
85-
date,
86-
LocalDate(2025, 1, 6),
87-
LocalDate(2025, 1, 10),
88-
)
89-
90-
val (fs, fel) = testDeconstruct(content)
91-
92-
commonTest(fs, listOf(4, 3, 3, 3, 3))
93-
commonTest(fel, listOf(3, 3, 3, 4, 4))
94-
@Suppress("SpellCheckingInspection")
95-
fs[1].dishList[2].run {
96-
type shouldBe "Hlavní jídlo 2"
97-
name shouldBe "Kuřecí steak s pikantní omáčkou, hranolky"
98-
price shouldBe 139
99-
}
100-
101-
commonTest(fel, listOf(4, 4, 3, 3, 5))
102-
@Suppress("SpellCheckingInspection")
103-
fel[4].dishList[1].run {
104-
type shouldBe "Hlavní jídlo 1"
105-
name shouldBe "Plněný paprikový lusk, houskové knedlíky (rýže )"
106-
price shouldBe 138
107-
}
108-
}
109-
110-
"Scrape 2025-01-13" {
111-
val log = Logger.withTag("2025-01-13")
112-
val html = loadPage("2025-01-13.html")
74+
"Scrape 2025-12-15" {
75+
val log = Logger.withTag("2025-12-15")
76+
val html = loadPage("2025-12-15.html")
11377
val scraper = scraper()
11478
val date = scraper.matchValidity(html)
11579
val content = scraper.matchContent(html)
@@ -125,21 +89,32 @@ class BuffetScraperTest :
12589

12690
val (fs, fel) = testDeconstruct(content)
12791

128-
commonTest(fs, listOf(4, 3, 3, 3, 3))
129-
commonTest(fel, listOf(3, 3, 3, 4, 4))
92+
commonTest(fs, listOf(3, 3, 3, 3, 3))
93+
commonTest(fel, listOf(3, 3, 4, 4, 3))
13094
@Suppress("SpellCheckingInspection")
13195
fs[1].dishList[2].run {
13296
type shouldBe "Hlavní jídlo 2"
133-
name shouldBe "Smažený květák, vařené brambory, tatarská omáčka"
134-
price shouldBe 139
97+
name shouldBe "Kuřecí steak s mexickou salsou, hranolky"
98+
price shouldBe 149
13599
}
100+
fs[1].dishList[0].run {
101+
type shouldBe "Polévka"
102+
name shouldBe "Gulášová"
103+
price shouldBe 40
104+
}
105+
// A "mistake" is present on the website where a label exists twice
106+
fs[4].dishList[1].type shouldBe fs[4].dishList[2].type
136107

137-
commonTest(fel, listOf(4, 4, 3, 3, 5))
138108
@Suppress("SpellCheckingInspection")
139-
fel[4].dishList[1].run {
109+
fel[0].dishList[1].run {
140110
type shouldBe "Hlavní jídlo 1"
141-
name shouldBe "Smažená aljašská treska, bramborová kaše"
142-
price shouldBe 136
111+
name shouldBe "Segedínský guláš, houskové knedlíky"
112+
price shouldBe 144
113+
}
114+
fel[4].dishList[2].run {
115+
type shouldBe "Hlavní jídlo 2"
116+
name shouldBe "Smažený kuřecí řízek, domácí bramborový salát"
117+
price shouldBe 149
143118
}
144119
}
145120

0 commit comments

Comments
 (0)