From f2af689e521da20a35b92cf9905bb961786b51fc Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Mon, 11 Sep 2017 15:36:21 -0600 Subject: [PATCH] Sort room list This provides a sorting of the room list by iterating the total list of rooms, and displaying information per room if available. Without this the order of rooms jumps on each save based on the fact that it's a dict/object and has no natural sort order. That can feel very confusing. Change-Id: I5375374091296cd7c23a3a8e2272aefcf6b2d896 --- html/ptg.html | 16 ++++++++++------ ptgbot/db.py | 1 + 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/html/ptg.html b/html/ptg.html index 888902f..4986ebf 100644 --- a/html/ptg.html +++ b/html/ptg.html @@ -27,12 +27,14 @@

Currently playing...

- {{#each now as |what room|}} + {{#each rooms as |room| }} + {{#if (lookup @root.now room) }} - + + {{/if}} {{else}} {{/each}} @@ -41,15 +43,17 @@

Coming up next...

{{room}}{{#hashtag}}{{what}}{{/hashtag}}{{#hashtag}}{{lookup @root.now room}}{{/hashtag}} {{lookup @root.location room}}
Nothing yet
- {{#each next as |sessions room|}} + {{#each rooms as |room| }} + {{#if (lookup @root.next room) }} + {{/if}} {{else}} {{/each}} diff --git a/ptgbot/db.py b/ptgbot/db.py index 71331d2..25f3f80 100644 --- a/ptgbot/db.py +++ b/ptgbot/db.py @@ -91,5 +91,6 @@ class PTGDataBase(): self.data['ethercalc'] = self.ethercalc.load() timestamp = datetime.datetime.now() self.data['timestamp'] = '{:%Y-%m-%d %H:%M:%S}'.format(timestamp) + self.data['rooms'] = sorted(self.data['rooms']) with open(self.filename, 'w') as fp: json.dump(self.data, fp)
{{room}} - {{#each sessions}} - {{#hashtag}}{{this}}{{/hashtag}}
- {{/each}} + {{#each (lookup @root.next room) as |item|}} + {{#hashtag}}{{item}}{{/hashtag}}
+ {{/each}}
Nothing yet