From 76b2eaf435766d854542cfc8e684dd4c724c5697 Mon Sep 17 00:00:00 2001
From: Josh Borrow <joshua.borrow@durham.ac.uk>
Date: Mon, 19 Mar 2018 15:16:27 +0000
Subject: [PATCH] Added a random number of seconds [0, 10000] to each datetime
 object to ensure that no two 'talks' have the same date.

---
 filters.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/filters.py b/filters.py
index 2088f84..7fc4481 100644
--- a/filters.py
+++ b/filters.py
@@ -7,7 +7,9 @@ http://jinja.pocoo.org/docs/2.9/api/#custom-filters
 Created 26-09-2017 by Josh Borrow (joshua.borrow@durham.ac.uk)
 """
 
+import datetime
 import dateutil.parser as dp
+from random import randint as rand
 
 def sort_cards(cards):
     """
@@ -22,8 +24,12 @@ def sort_cards(cards):
     A list will be returned where the cards are sorted by date.
     """
 
+    # We add a random number of seconds in case we have a number of
+    # cards on the same date.
+
     dates = [
-        dp.parse(card["date"]) for card in cards
+        dp.parse(card["date"]) + datetime.timedelta(rand(0, 10000))
+        for card in cards
     ]
 
     _, cards = zip(*sorted(zip(dates, cards)))
-- 
GitLab