|
|
@@ -123,18 +123,22 @@ def home(request):
|
|
123
|
123
|
counter.lastReset.delta, locale='fr', threshold=1)
|
|
124
|
124
|
counter.isHidden = 'hidden'
|
|
125
|
125
|
|
|
126
|
|
- # Now we sort the counters according to a reddit-like ranking formula
|
|
127
|
|
- # We take into account the number of likes of a reset and its recentness
|
|
128
|
|
- # The log on the score will give increased value to the first likes
|
|
129
|
|
- # The negative exp for the time with a characteristic time of 1 day will
|
|
130
|
|
- # cause that after 1 day the « recentness score drops from 1 to 0.36
|
|
131
|
|
- # The counters with no seum have a like count of -1 by convention
|
|
132
|
|
- counters = sorted(counters, key=lambda t: - (
|
|
133
|
|
- math.log(t.likeCount + 2) /
|
|
134
|
|
- (1 + (t.lastReset.delta.total_seconds()) /
|
|
135
|
|
- (24 * 3600))))
|
|
136
|
|
-
|
|
137
|
|
- # Column graph
|
|
|
126
|
+ if myCounter.sort_by_score:
|
|
|
127
|
+ # Now we sort the counters according to a reddit-like ranking formula
|
|
|
128
|
+ # We take into account the number of likes of a reset and its recentness
|
|
|
129
|
+ # The log on the score will give increased value to the first likes
|
|
|
130
|
+ # The negative exp for the time with a characteristic time of 1 day will
|
|
|
131
|
+ # cause that after 1 day the « recentness score drops from 1 to 0.36
|
|
|
132
|
+ # The counters with no seum have a like count of -1 by convention
|
|
|
133
|
+ counters = sorted(counters, key=lambda t: - (
|
|
|
134
|
+ math.log(t.likeCount + 2) /
|
|
|
135
|
+ (1 + (t.lastReset.delta.total_seconds()) /
|
|
|
136
|
+ (24 * 3600))))
|
|
|
137
|
+ else:
|
|
|
138
|
+ counters = sorted(counters, key=lambda t: +
|
|
|
139
|
+ t.lastReset.delta.total_seconds())
|
|
|
140
|
+
|
|
|
141
|
+ # Column graph
|
|
138
|
142
|
if (len(lastResets) == 0):
|
|
139
|
143
|
noGraph = True
|
|
140
|
144
|
col_chart = None
|
|
|
@@ -466,6 +470,14 @@ def toggleEmailNotifications(request):
|
|
466
|
470
|
|
|
467
|
471
|
|
|
468
|
472
|
@login_required
|
|
|
473
|
+def toggleScoreSorting(request):
|
|
|
474
|
+ counter = Counter.objects.get(user=request.user)
|
|
|
475
|
+ counter.sort_by_score = not counter.sort_by_score
|
|
|
476
|
+ counter.save()
|
|
|
477
|
+ return HttpResponseRedirect(reverse('home'))
|
|
|
478
|
+
|
|
|
479
|
+
|
|
|
480
|
+@login_required
|
|
469
|
481
|
def like(request):
|
|
470
|
482
|
if (request.method == 'POST'):
|
|
471
|
483
|
# create a form instance and populate it with data from the request:
|