Skip to content

Instantly share code, notes, and snippets.

Created December 26, 2013 01:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/8128507 to your computer and use it in GitHub Desktop.
Save anonymous/8128507 to your computer and use it in GitHub Desktop.
How V2EX decides topic order
# Logic to decide how this reply affects ranking of the topic
now = self.now()
diff = now - topic.last_touched
if topic.last_touched < now:
if topic.old_topic:
if diff > 86400:
topic.last_touched = topic.last_touched + int(diff / 8)
else:
if diff > (3600 * 4):
topic.last_touched = topic.last_touched + 3600
else:
if diff < 3600:
topic.last_touched = now
else:
topic.last_touched = topic.last_touched + 600
else:
if diff > 86400:
topic.last_touched = topic.last_touched + int(diff / 4)
else:
if diff > (3600 * 4):
topic.last_touched = topic.last_touched + 3600
else:
topic.last_touched = now
else:
# Extension: 60s to sticky topic
topic.last_touched = topic.last_touched + 60
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment