From f8feb2584f121c918814b71dde2adc643dbd9782 Mon Sep 17 00:00:00 2001 From: Nathaniel Smith Date: Sun, 28 Dec 2014 18:46:07 -0800 Subject: [PATCH] tweak username sorting --- scripts/userlist.hy | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/scripts/userlist.hy b/scripts/userlist.hy index 3c98a67..9fddff8 100644 --- a/scripts/userlist.hy +++ b/scripts/userlist.hy @@ -2,6 +2,8 @@ (import [os.path [getmtime]]) (import [datetime [datetime]]) +(import [sh [find]]) + ;; this script emits HTML on standard out that constitutes a user ;; list. It denotes who has not updated their page from the ;; default. It also reports the time this script was run. @@ -25,15 +27,18 @@ "")))) (defn modify-time [username] - (getmtime (.format "/home/{}/public_html" username))) - + (->> (.format "/home/{}/public_html" username) + find + (map (fn [filename] (getmtime (.rstrip filename)))) + list + max)) (defn sort-user-list [usernames] (apply sorted [usernames] {"key" modify-time})) (defn user-generator [] (->> (listdir "/home") - (filter (fn [f] (and (not (= f "ubuntu")) (not (= f "poetry"))))) - list)) + (filter (fn [f] (and (not (= f "ubuntu")) (not (= f "poetry"))))))) + ;list)) (def user-list (->> (user-generator) sort-user-list