all progress mapped out

This commit is contained in:
Michael Zhang 2024-07-11 10:15:26 -05:00
parent 56394e55aa
commit 41c18cdd32
3 changed files with 64 additions and 10 deletions

View file

@ -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

View file

@ -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;

View file

@ -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" }
$"<div data-ch=\"($n)\" class=\"cell\" style=\"
background-color: ($color);
color: ($textColor);
\">
<h3>($n)</h3>
<small>($completed) / ($total)</small>
<small style=\"font-size: 0.5rem;\">($percent)%</small>
</div>" | 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