Browse Source

Pre-allocate random colors

Pre-allocate badge colors from a palette so that everyone is
not blue.

Change-Id: Id72711803e708dd51a4a1121bdd54dba30801ac0
changes/86/540886/1
Thierry Carrez 3 years ago
parent
commit
05ae383f69
1 changed files with 16 additions and 1 deletions
  1. +16
    -1
      ptgbot/db.py

+ 16
- 1
ptgbot/db.py View File

@ -15,10 +15,11 @@
# limitations under the License.
import calendar
import datetime
from itertools import chain
import json
import os
import datetime
import random
class PTGDataBase():
@ -41,6 +42,20 @@ class PTGDataBase():
for time, track in bookings.items():
if track not in self.data['tracks']:
self.data['tracks'].append(track)
self.data['colors'][track] = random.choice([
'#596468',
'#9ea8ad',
'#b57506',
'#f8ac29',
'#5b731a',
'#9dc62d',
'#156489',
'#27a3dd',
'#2a6d3c',
'#3fa45b',
'#930a0a',
'#dc0d0e',
])
# Rebuild 'additional' with rooms and slots from configuration, but
# use saved data where the room/slot is preserved


Loading…
Cancel
Save