|
|
@@ -69,6 +69,7 @@ def home(request):
|
|
69
|
69
|
counter.lastReset.delta = no_seum_delta
|
|
70
|
70
|
counter.lastReset.noSeum = True
|
|
71
|
71
|
counter.CSSclass = "warning"
|
|
|
72
|
+ counter.likeCount = -1
|
|
72
|
73
|
else: # This person already had the seum
|
|
73
|
74
|
counter.lastReset = lastReset[0]
|
|
74
|
75
|
# To display the last seum we have to know if it is self-inflicted
|
|
|
@@ -98,9 +99,6 @@ def home(request):
|
|
98
|
99
|
(24 * 3600))
|
|
99
|
100
|
# Defining CSS attributes for the counter
|
|
100
|
101
|
counter.CSSclass = "default"
|
|
101
|
|
- counter.opacity = 0.4 + 0.6 * \
|
|
102
|
|
- math.exp(-(counter.lastReset.delta.total_seconds()) /
|
|
103
|
|
- (7 * 24 * 3600))
|
|
104
|
102
|
# Computing the total number of likes for this counter
|
|
105
|
103
|
counter.likeCount = Like.objects.filter(
|
|
106
|
104
|
reset=counter.lastReset).count()
|
|
|
@@ -111,8 +109,16 @@ def home(request):
|
|
111
|
109
|
counter.lastReset.delta, locale='fr', threshold=1)
|
|
112
|
110
|
counter.isHidden = "hidden"
|
|
113
|
111
|
|
|
114
|
|
- # Eventually we sort the counters to display the most recent resets top
|
|
115
|
|
- counters = sorted(counters, key=lambda t: t.lastReset.delta)
|
|
|
112
|
+ # Now we sort the counters according to a reddit-like ranking formula
|
|
|
113
|
+ # We take into account the number of likes of a reset and its recentness
|
|
|
114
|
+ # The log on the score will give increased value to the first likes
|
|
|
115
|
+ # The negative exp for the time with a characteristic time of 1 day will
|
|
|
116
|
+ # cause that after 1 day the « recentness score drops from 1 to 0.36
|
|
|
117
|
+ # The counters with no seum have a like count of -1 by convention
|
|
|
118
|
+ counters = sorted(counters, key=lambda t: - (
|
|
|
119
|
+ math.log(t.likeCount + 2) *
|
|
|
120
|
+ math.exp(-(t.lastReset.delta.total_seconds()) /
|
|
|
121
|
+ (24 * 3600))))
|
|
116
|
122
|
|
|
117
|
123
|
# Column graph
|
|
118
|
124
|
if (len(lastResets) == 0):
|
|
|
@@ -360,8 +366,8 @@ def counter(request, id_counter):
|
|
360
|
366
|
if reset.selfSeum:
|
|
361
|
367
|
reset.Seum = {'v': 0, 'f': reset.reason}
|
|
362
|
368
|
else:
|
|
363
|
|
- reset.Seum = {'v': 0, 'f': 'De ' + reset.who.trigramme + ' : ' +
|
|
364
|
|
- reset.reason}
|
|
|
369
|
+ reset.Seum = {'v': 0, 'f': 'De ' +
|
|
|
370
|
+ reset.who.trigramme + ' : ' + reset.reason}
|
|
365
|
371
|
# Drawing the graph
|
|
366
|
372
|
data = ModelDataSource(
|
|
367
|
373
|
resets, fields=['timestamp', 'Seum'])
|