From 41c18cdd328ce805b246631f9578b1953bd34b5b Mon Sep 17 00:00:00 2001 From: Michael Zhang Date: Thu, 11 Jul 2024 10:15:26 -0500 Subject: [PATCH] all progress mapped out --- Makefile | 21 ++++++++++++------ html/ProgressHeader.html | 5 +++++ scripts/build-table | 48 +++++++++++++++++++++++++++++++++++++--- 3 files changed, 64 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 97f8808..23f85bd 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,5 @@ GENDIR := html/src/generated +AGDA_SOURCES := $(shell find src -not \( -path src/Misc -prune \) \( -name "*.agda" -o -name "*.lagda.md" \) ) build-to-html: nu scripts/build-table @@ -15,23 +16,29 @@ build-to-html: || true fd --no-ignore "html$$" $(GENDIR) -x rm -build-book: build-to-html - mdbook build html +.PHONY: html/src/generated/Progress.md + +html/src/generated/Progress.md: + nu scripts/build-table > /dev/null + +html/book/Progress.html: html/src/generated/Progress.md pandoc \ -f markdown-markdown_in_html_blocks+raw_html \ -t html \ -i html/src/generated/Progress.md \ > html/book/Progress.html + +html/book/progress/index.html: html/book/Progress.html + cat html/ProgressHeader.html $^ > $@ + +build-book: build-to-html + mdbook build html mkdir -p html/book/progress - cat \ - html/ProgressHeader.html \ - html/book/Progress.html \ - > html/book/progress/index.html refresh-book: build-to-html mdbook serve html -deploy: build-book +deploy: build-book html/book/Progress.html rsync -azr html/book/ root@veil:/home/blogDeploy/public/research .PHONY: build-book build-to-html deploy diff --git a/html/ProgressHeader.html b/html/ProgressHeader.html index 19bc558..aed3338 100644 --- a/html/ProgressHeader.html +++ b/html/ProgressHeader.html @@ -11,9 +11,14 @@ font-weight: bold; src: url(https://mzhang.io/fonts/Inter-Bold.ttf) format(truetype); } + body { font-family: "Inter", sans-serif; } + h3 { margin: 0; } + table { border-spacing: 0; } + .cell { display: flex; + flex-direction: column; min-height: 48px; align-items: center; justify-content: center; diff --git a/scripts/build-table b/scripts/build-table index a8c74d3..5943dc3 100755 --- a/scripts/build-table +++ b/scripts/build-table @@ -4,6 +4,9 @@ let chapters = { 2: 7, 3: 9, 4: 19, + 6: 15, + 7: 21, + 8: 22, } let gradients = [ @@ -43,22 +46,55 @@ let viz = { |k, n| # $n | math round --precision 1 } +let vizCh = { |n, table| + let noExercises = $table | where type != "Exercise" + let completed = $noExercises | where completed == "x" | length + let total = $noExercises | where type != "Exercise" | length + let ratio = if $total != 0 { $completed / $total } else { 0 } + let percent = ($ratio * 100 | math round --precision 1) + let color = if $n == 0 { "gray" } else { do $interpColor $ratio } + let textColor = if $completed == $total { "gold" } else { "white" } + + $"
+

($n)

+ ($completed) / ($total) + ($percent)% +
" | str replace -a "\n" "" +} + let vizChapter = { |n| let nStr = $n | into string let url = $"https://git.mzhang.io/api/v1/repos/school/type-theory/issues/($chapters | get $nStr)" - curl -s $url + let table = curl -s $url | jq -r .body | lines | rg -o $"\\[\(x| \)\\] \(.*\) \(\\d+\(\\.\\d+\)*\)" -r "$1,$2,$3" | from csv --noheaders | rename completed type number | insert section { if $in.type == "Exercise" { "Exercise" } else { $in.number | split row "." | get 1 } } + + let table2 = $table | group-by section | transpose | each { $in | update column1 { do $viz ($in | where completed == "x" | length) ($in | length) } } | sort-by -n column0 - | prepend { column0: "Ch", column1: $n } + + print ($table2 | table) + + let newColumn1 = { column0: "Ch", column1: (do $vizCh $n $table) } + let newColumn2 = { column0: "Chnum", column1: $n } + + let table3 = if ($table2 | is-empty) { + [$newColumn1, $newColumn2] + } else { + $table2 | prepend $newColumn1 | prepend $newColumn2 + } + + $table3 | transpose -r } @@ -66,7 +102,13 @@ $chapters | columns | each { do $vizChapter $in } | reduce {|it, acc| $acc | append $it } - | sort-by Ch + | sort-by Chnum + | reject Chnum + | transpose + | sort-by -n column0 + | transpose -r + | move Ch --before 0 + | to md | tee { save -f html/src/generated/Progress.md } # open breakdown.json