From 259750277a67bcc89377cbe9456c463cb3f5a59a Mon Sep 17 00:00:00 2001
From: Vincent Ambo
---
ci-builds.nix | 1 +
web/todolist/default.nix | 113 ++++++++++++++++++++++++++++++++++
web/todolist/extract-todos.jq | 25 ++++++++
3 files changed, 139 insertions(+)
create mode 100644 web/todolist/default.nix
create mode 100644 web/todolist/extract-todos.jq
diff --git a/ci-builds.nix b/ci-builds.nix
index 2e4e40392..349ce9e98 100644
--- a/ci-builds.nix
+++ b/ci-builds.nix
@@ -74,6 +74,7 @@ in lib.fix (self: {
tools.cheddar
tools.nsfv-setup
web.cgit-taz
+ web.todolist
web.tvl
(drvify "getBins-tests" nix.getBins.tests)
]
diff --git a/web/todolist/default.nix b/web/todolist/default.nix
new file mode 100644
index 000000000..187830e73
--- /dev/null
+++ b/web/todolist/default.nix
@@ -0,0 +1,113 @@
+# Generates a simple web view of open TODOs in the depot.
+#
+# Only TODOs that match the form 'TODO($username)' are considered, and
+# only for users that are known to us.
+{ depot, lib, ... }:
+
+with depot.nix.yants;
+
+let
+ inherit (depot.third_party)
+ jq
+ ripgrep
+ runCommandNoCC
+ writeText
+ ;
+
+ inherit (builtins)
+ elem
+ filter
+ fromJSON
+ head
+ readFile
+ ;
+
+ inherit (lib) concatStringsSep;
+
+ # We should extract this from TVL slapd, but that data is not easily
+ # accessible right now.
+ knownUsers = [
+ "tazjin"
+ "riking"
+ "Profpatsch"
+ "grfn"
+ "lukegb"
+ ];
+
+ todo = struct {
+ file = string;
+ line = int;
+ todo = string;
+ user = string;
+ };
+
+ allTodos = fromJSON (readFile (runCommandNoCC "depot-todos.json" {} ''
+ ${ripgrep}/bin/rg --json 'TODO\(\w+\):.*$' ${depot.depotPath} | \
+ ${jq}/bin/jq -s -f ${./extract-todos.jq} > $out
+ ''));
+
+ knownUserTodos = filter (todos: elem (head todos).user knownUsers) allTodos;
+
+ fileLink = defun [ todo string ] (t:
+ ''
+ //${t.file}:${toString t.line}'');
+
+ todoElement = defun [ todo string ] (t: ''
+ At ${fileLink t}:
+ ${t.todo}
+
+ '');
+
+ userParagraph = todos:
+ let user = (head todos).user;
+ in ''
+
+ ${user}
+ ${concatStringsSep "\n" (map todoElement todos)}
+