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))
|
note := renderNote(pkg, "https://x.test/job", time.Date(2026, 11, 24, 10, 0, 0, 0, time.UTC))
|
||||||
for _, want := range []string{
|
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",
|
"- **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]]",
|
"## Cover letter draft\nDear hiring team,", "## Related\n- [[00-Job Hunt|Job Hunt]]\n- [[CV]]",
|
||||||
} {
|
} {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
@@ -43,11 +44,22 @@ func bullets(b *strings.Builder, heading string, items []string) {
|
|||||||
b.WriteString("\n")
|
b.WriteString("\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
// renderNote writes the package as a vault note: small frontmatter, plain
|
// yamlString quotes a value for the frontmatter. A JSON string is also a
|
||||||
// title, a Related section at the end.
|
// 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 {
|
func renderNote(pkg *Package, url string, now time.Time) string {
|
||||||
var b strings.Builder
|
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, "# %s\n\n", noteName(pkg))
|
||||||
fmt.Fprintf(&b, "- [ ] Review and decide: **%s**, fit %d/100\n\n", strings.ToLower(pkg.Verdict), pkg.FitScore)
|
fmt.Fprintf(&b, "- [ ] Review and decide: **%s**, fit %d/100\n\n", strings.ToLower(pkg.Verdict), pkg.FitScore)
|
||||||
if pkg.VerdictReason != "" {
|
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)
|
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