Commits

Julio Biason  committed 0e236af

added proper rotation to the incoming selections

  • Participants
  • Parent commits 4a9f2c8

Comments (0)

Files changed (1)

File aweek/main/views.py

 
 main = Blueprint('main',
                  __name__,
-                 template_folder='../templates/main')
+                 template_folder='../templates')
 
 _log = logging.getLogger('aweek.main')
 
         query = {'date': {'$gte': last_4_weeks}}
 
         objs = Picks.objects(query).order_by('+date')
+        _log.debug('{} entries'.format(objs.count()))
 
         # people who will pick it next
         future = []
-        all_users = User.objects.all()
+        all_users = User.objects.all().order_by('+joined')
+
+        last_user = None
+        if objs.count() > 0:
+            gather = False
+        else:
+            gather = True   # no picks in the db, so we get everyone
 
-        gather = False
         for user in all_users:
+            _log.debug('Gathering? {}'.format('YES' if gather else 'NO'))
             if gather:
                 future.append(user)
+            elif user.pk == last_user:
+                gather = True
 
             if len(future) >= 4:
                 break
 
-            if user._id == objs.user:
-                gather = True
-
         if len(future) < 4:
             needed = 4 - len(future)
             future.extend(all_users[:needed])
 
+        _log.debug(future)
+
         return render_template('index.html', previous=objs, next=future)