Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: filters/teamsort.py

Issue 29334171: Issue 3410 - Added date sort / format for press releases (Closed)
Patch Set: Fixed datetime call Created Feb. 9, 2016, 4 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « filters/humanize_date.py ('k') | includes/press/releases.tmpl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: filters/teamsort.py
diff --git a/filters/teamsort.py b/filters/teamsort.py
new file mode 100644
index 0000000000000000000000000000000000000000..70bc2ee98c8d891d98d773f98cf1d107f30e53aa
--- /dev/null
+++ b/filters/teamsort.py
@@ -0,0 +1,10 @@
+import random
+from datetime import datetime
+
+def teamsort(value, basedate="1970-01-01", column=0):
+ base = datetime.strptime(basedate, "%Y-%m-%d")
+ def randdiff(entry):
+ date = datetime.strptime(entry[column], "%Y-%m-%d")
+ diff = (date - base).days
+ return diff * 0.2 + random.randrange(diff) * 0.8
+ return sorted(value, key=randdiff)
« no previous file with comments | « filters/humanize_date.py ('k') | includes/press/releases.tmpl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld