mirror of
https://github.com/MadsLorentzen/ai-job-search.git
synced 2026-11-02 13:12:50 +00:00
fix(salary): prefer exact workbook identity headers (#571)
* fix(salary): prefer exact workbook identity headers * docs(changelog): record fix for #571
This commit is contained in:
1 parent
652508a929
commit
8cc2efbf21
3 files changed
+61
No files matched your search
@@ -211,6 +211,8 @@ per-file diff commands.
|
||||
RFC 9309 section 2.2.3, `$` is an end anchor only at the end of the pattern, and internal `$`
|
||||
characters are now matched literally.
|
||||
|
||||
- **Salary workbook conversion prefers exact identity headers** (#571) - exact company column names take precedence over incidental substring matches in other headers.
|
||||
|
||||
- **CV template guidance aligns geometry scale with master template** (#553,
|
||||
`.claude/skills/job-application-assistant/05-cv-templates.md`, `tests/test_latex_guidance.py`) -
|
||||
the preamble snippet in `05-cv-templates.md` specified `\usepackage[scale=0.77]{geometry}`,
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
"""A salary category must not steal the workbook's company-name column."""
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
from tempfile import TemporaryDirectory
|
||||
|
||||
try:
|
||||
import openpyxl
|
||||
except ImportError:
|
||||
openpyxl = None
|
||||
|
||||
TOOL = Path(__file__).resolve().parent.parent / "tools" / "convert_salary_excel.py"
|
||||
|
||||
|
||||
@unittest.skipUnless(openpyxl, "requires optional openpyxl (installed in CI)")
|
||||
class CompanyHeaderCLI(unittest.TestCase):
|
||||
def convert(self, header):
|
||||
with TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
workbook, output = root / "salary.xlsx", root / "salary.json"
|
||||
book = openpyxl.Workbook()
|
||||
try:
|
||||
book.active.append(header)
|
||||
book.active.append(["Acme Corp", "Berlin", 25, 108.5])
|
||||
book.save(workbook)
|
||||
finally:
|
||||
book.close()
|
||||
result = subprocess.run(
|
||||
[sys.executable, str(TOOL), str(workbook), "--output", str(output)],
|
||||
capture_output=True, text=True, encoding="utf-8",
|
||||
)
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
return json.loads(output.read_text(encoding="utf-8"))["companies"]
|
||||
|
||||
def test_company_prefixed_salary_columns_do_not_replace_the_company(self):
|
||||
self.assertEqual(self.convert(["Company", "City", "Company Count", "Company Index"]), [
|
||||
{"company": "Acme Corp", "city": "Berlin", "categories": {
|
||||
"company": {"count": 25, "index": 108.5}}}
|
||||
])
|
||||
|
||||
def test_existing_named_category_control(self):
|
||||
self.assertEqual(self.convert(["Company Name", "City", "Engineering Count", "Engineering Index"]), [
|
||||
{"company": "Acme Corp", "city": "Berlin", "categories": {
|
||||
"engineering": {"count": 25, "index": 108.5}}}
|
||||
])
|
||||
|
||||
def test_city_prefixed_salary_columns_do_not_replace_the_city(self):
|
||||
self.assertEqual(self.convert(["Company", "City", "City Count", "City Index"]), [
|
||||
{"company": "Acme Corp", "city": "Berlin", "categories": {
|
||||
"city": {"count": 25, "index": 108.5}}}
|
||||
])
|
||||
@@ -191,6 +191,12 @@ def parse_sheet(ws, sheet_label=None):
|
||||
elif header_matches(h, CITY_PATTERNS):
|
||||
city_col = i
|
||||
|
||||
# A qualified salary header such as "Company Index" may also contain a
|
||||
# metadata token. Prefer an unqualified metadata column when one exists,
|
||||
# leaving the qualified column available as salary data.
|
||||
company_col = next((i for i, h in enumerate(headers) if h.lower() in COMPANY_PATTERNS), company_col)
|
||||
city_col = next((i for i, h in enumerate(headers) if h.lower() in CITY_PATTERNS), city_col)
|
||||
|
||||
if company_col is None:
|
||||
print(f"Warning: Could not find company column in sheet '{ws.title}'.", file=sys.stderr)
|
||||
return []
|
||||
|
||||
Reference in new issue
Block a user