Sort menu items: active first, then by price asc, then by number
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -39,6 +39,8 @@ function formatMenu(menu: ParsedMenu): string {
|
||||
}
|
||||
|
||||
const sorted = [...menu.items].sort((a, b) => {
|
||||
if (a.inactive !== b.inactive) return a.inactive ? 1 : -1
|
||||
if (a.price !== b.price) return a.price - b.price
|
||||
const na = parseInt(a.name.match(/^(\d+)\./)?.[1] ?? "99", 10)
|
||||
const nb = parseInt(b.name.match(/^(\d+)\./)?.[1] ?? "99", 10)
|
||||
return na - nb
|
||||
@@ -58,6 +60,7 @@ async function tg(text: string): Promise<void> {
|
||||
return
|
||||
}
|
||||
await sendMessage(config.telegram.botToken, config.telegram.chatId, text)
|
||||
console.log(`TG sent: ${text.slice(0, 80)}${text.length > 80 ? "…" : ""}`)
|
||||
}
|
||||
|
||||
async function main() {
|
||||
|
||||
Reference in New Issue
Block a user