feat: write company, role, fit, verdict, location and posting as note properties
This commit is contained in:
+1
-1
@@ -252,7 +252,7 @@ func TestRenderNote(t *testing.T) {
|
||||
}
|
||||
note := renderNote(pkg, "https://x.test/job", time.Date(2026, 11, 24, 10, 0, 0, 0, time.UTC))
|
||||
for _, want := range []string{
|
||||
"moc: \"[[00-Job Hunt]]\"\ncreated: 2026-11-24", "# Acme - Backend Engineer", "- [ ] Review and decide: **apply**, fit 82/100",
|
||||
"moc: \"[[00-Job Hunt]]\"\ncreated: 2026-11-24\ncompany: \"Acme\"\nrole: \"Backend Engineer\"\nfit: 82\nverdict: \"apply\"\nlocation: \"Utrecht\"\nposting: \"https://x.test/job\"\n---", "# Acme - Backend Engineer", "- [ ] Review and decide: **apply**, fit 82/100",
|
||||
"- **Posting:** https://x.test/job", "## Strengths\n- Go at Ghaaf", "## Gaps\n- No Dutch",
|
||||
"## Cover letter draft\nDear hiring team,", "## Related\n- [[00-Job Hunt|Job Hunt]]\n- [[CV]]",
|
||||
} {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
@@ -43,11 +44,22 @@ func bullets(b *strings.Builder, heading string, items []string) {
|
||||
b.WriteString("\n")
|
||||
}
|
||||
|
||||
// renderNote writes the package as a vault note: small frontmatter, plain
|
||||
// title, a Related section at the end.
|
||||
// yamlString quotes a value for the frontmatter. A JSON string is also a
|
||||
// valid YAML double-quoted string, whatever the posting put in it.
|
||||
func yamlString(s string) string {
|
||||
b, _ := json.Marshal(strings.Join(strings.Fields(s), " "))
|
||||
return string(b)
|
||||
}
|
||||
|
||||
// renderNote writes the package as a vault note: frontmatter, plain title, a
|
||||
// Related section at the end. The properties after `created` are the columns
|
||||
// of the vault's "Job Hunt" base (the table of all postings).
|
||||
func renderNote(pkg *Package, url string, now time.Time) string {
|
||||
var b strings.Builder
|
||||
fmt.Fprintf(&b, "---\nmoc: \"[[00-Job Hunt]]\"\ncreated: %s\n---\n\n", now.Format("2006-01-02"))
|
||||
fmt.Fprintf(&b, "---\nmoc: \"[[00-Job Hunt]]\"\ncreated: %s\n", now.Format("2006-01-02"))
|
||||
fmt.Fprintf(&b, "company: %s\nrole: %s\nfit: %d\nverdict: %s\nlocation: %s\nposting: %s\n---\n\n",
|
||||
yamlString(pkg.Company), yamlString(pkg.Title), pkg.FitScore, yamlString(strings.ToLower(pkg.Verdict)),
|
||||
yamlString(pkg.Location), yamlString(url))
|
||||
fmt.Fprintf(&b, "# %s\n\n", noteName(pkg))
|
||||
fmt.Fprintf(&b, "- [ ] Review and decide: **%s**, fit %d/100\n\n", strings.ToLower(pkg.Verdict), pkg.FitScore)
|
||||
if pkg.VerdictReason != "" {
|
||||
|
||||
@@ -332,3 +332,10 @@ func TestParsePackageMalformedAnswer(t *testing.T) {
|
||||
t.Errorf("the error should quote the answer near the fault, got %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestYAMLString(t *testing.T) {
|
||||
// A hostile or just odd title must stay one quoted scalar in the frontmatter.
|
||||
if got, want := yamlString("Engineer: \"Core\"\n---\nfit: 100"), `"Engineer: \"Core\" --- fit: 100"`; got != want {
|
||||
t.Errorf("yamlString = %s, want %s", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user