From 0ff25fb301a500ef74c971551d914e791bf63fa4 Mon Sep 17 00:00:00 2001 From: Franziska Kunsmann Date: Thu, 26 Dec 2024 10:54:56 +0100 Subject: [PATCH] sort talks in python, only sort by time this assumes the room order in the schedule.json is the correct order --- node.lua | 6 ------ service | 2 ++ tile.lua | 7 ------- 3 files changed, 2 insertions(+), 13 deletions(-) diff --git a/node.lua b/node.lua index b7fd7eb..50da3d6 100644 --- a/node.lua +++ b/node.lua @@ -96,12 +96,6 @@ local function check_next_talks() all_next_talks[#all_next_talks+1] = talk end end - - local function sort_talks(a, b) - return a.start_ts < b.start_ts or (a.start_ts == b.start_ts and a.room < b.room) - end - - table.sort(all_next_talks, sort_talks) end local function wrap(str, font, size, max_w) diff --git a/service b/service index a7266f9..d3f5965 100755 --- a/service +++ b/service @@ -151,6 +151,7 @@ def main(): "color": color, } ) + schedule["talks"] = sorted(schedule["talks"], key=lambda t: t["start_ts"]) node.write_json("schedule.json", schedule) log("updated schedule json") elif config["json_flavour"] == "voc-schema": @@ -236,6 +237,7 @@ def main(): talk["persons"] = persons schedule["talks"].append(talk) + schedule["talks"] = sorted(schedule["talks"], key=lambda t: t["start_ts"]) node.write_json("schedule.json", schedule) log("updated schedule json") else: diff --git a/tile.lua b/tile.lua index 7d1becc..318d810 100644 --- a/tile.lua +++ b/tile.lua @@ -151,13 +151,6 @@ local function check_next_talks() end end - local function sort_talks(a, b) - return a.start_ts < b.start_ts or (a.start_ts == b.start_ts and a.room < b.room) - end - - table.sort(room_next_talks, sort_talks) - table.sort(all_next_talks, sort_talks) - log(tostring(#all_next_talks) .. " talks to come") log(tostring(#room_next_talks) .. " in this room") end