val explain : exn -> string
val tokens : unit -> string
val tokensForked : unit -> unit
+
+ val usersDiff : string list * string list ->
+ {onlyInFirst : string list, onlyInSecond : string list}
+ val listUsernames : unit -> string list
+ val usersInAfs : unit -> string list
end
false)
handle OS.SysErr _ => true) (listActiveUsers ())
+fun usersDiff (ls1, ls2) =
+ {onlyInFirst = List.filter (fn x => not (Util.mem (x, ls2))) ls1,
+ onlyInSecond = List.filter (fn x => not (Util.mem (x, ls1))) ls2}
+
+fun listUsernames () = C.map (getDb ())
+ (fn [name] => C.stringFromSql name
+ | row => rowError ("listUsernames", row))
+ "SELECT name FROM WebUserActive ORDER BY name"
+fun usersInAfs () =
+ let
+ fun explore (dir, level, acc) =
+ if level = 3 then
+ dir :: acc
+ else
+ let
+ val dr = Posix.FileSys.opendir dir
+
+ fun loop acc =
+ case Posix.FileSys.readdir dr of
+ NONE => acc
+ | SOME name =>
+ let
+ val dir' = OS.Path.joinDirFile {dir = dir,
+ file = name}
+
+ val acc = explore (dir', level+1, acc)
+ in
+ loop acc
+ end
+ in
+ loop acc
+ before Posix.FileSys.closedir dr
+ end
+
+ val acc = explore ("/afs/hcoop.net/user", 0, [])
+ in
+ List.map OS.Path.file acc
+ end
+
end
<p><% negative %> have negative balances.</p>
+<% elseif $"cmd" = "diff" then
+ showNormal := false;
+
+ val against = (case $"against" of
+ "" => Init.usersInAfs ()
+ | x => String.tokens Char.isSpace x);
+
+ val diff = Init.usersDiff (Init.listUsernames (), against) %>
+
+<h3>User diff</h3>
+
+<h4>Only on the portal:</h4>
+<ul>
+<% foreach user in #onlyInFirst diff do %>
+ <li> <a href="user?id=<% valOf (Init.userNameToId user) %>"><% Web.html user %></a></li>
+<% end %>
+</ul>
+
+<h4>Only in AFS:</h4>
+<ul>
+<% foreach user in #onlyInSecond diff do %>
+ <li> <% Web.html user %></li>
+<% end %>
+</ul>
+
<% end %>
<% if showNormal then %>
<br><a href="users?cmd=grandfather">Grandfather old users to have applications</a><br>
<a href="users?cmd=unmigrated">Who hasn't migrated yet?</a><br>
+<a href="users?cmd=diff">How does the set of users in AFS compare with the set of active portal users?</a><br>
<% end %>