Keep a typed careers link, seed the by-hand reason and add the by-hand commands to app companies
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a466ea52b7
commit
b3cb93d5aa
3 files changed
+472
-15
No files matched your search
+121
-6
@@ -3,7 +3,7 @@
|
||||
app serve [--host H] [--port P] [--reload]
|
||||
app job pull|extract|embed|score [--payload JSON]
|
||||
app worker [--workers http=8,cpu=1] [--until-idle]
|
||||
app companies seed|add|set-board|detach|discover|check
|
||||
app companies seed|add|edit|checked|remove|by-hand|set-board|detach|discover|check
|
||||
app searches add|list|remove
|
||||
app agents list|prompt
|
||||
app stages [extract|summarise on|off]
|
||||
@@ -44,6 +44,8 @@ if str(_ROOT) not in sys.path:
|
||||
|
||||
|
||||
def build_parser() -> argparse.ArgumentParser:
|
||||
from app.models import HAND_REASONS
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
prog="app", description="roledesk: a job-search engine on desk and the pipeline queue.")
|
||||
parser.add_argument("-c", "--config", default=None,
|
||||
@@ -71,10 +73,34 @@ def build_parser() -> argparse.ArgumentParser:
|
||||
seed = companies_sub.add_parser(
|
||||
"seed", help="import seed/companies.json, and the boards it names for rows without one")
|
||||
seed.add_argument("--path", default="seed/companies.json")
|
||||
# One word after `add` is a company for the list checked by hand, two are
|
||||
# a board and its company, which is what `add` meant before that list.
|
||||
add = companies_sub.add_parser(
|
||||
"add", help="follow a company by its board, attaching or replacing an existing one's")
|
||||
add.add_argument("board", help="host:slug, e.g. greenhouse:acme")
|
||||
add.add_argument("name")
|
||||
"add", help="add NAME to the list checked by hand, or with BOARD NAME follow a "
|
||||
"company by its board, attaching or replacing an existing one's")
|
||||
add.add_argument("first", metavar="NAME|BOARD",
|
||||
help="the company, or host:slug, e.g. greenhouse:acme, before its name")
|
||||
add.add_argument("second", metavar="NAME", nargs="?")
|
||||
add.add_argument("--careers-url", default="", help="its careers page, http or https")
|
||||
add.add_argument("--note", default="")
|
||||
add.add_argument("--reason", default="added", choices=HAND_REASONS, metavar="REASON",
|
||||
help=f"one of {', '.join(repr(r) for r in HAND_REASONS)}")
|
||||
edit = companies_sub.add_parser("edit", help="change a company's name, link, note or reason")
|
||||
edit.add_argument("key")
|
||||
edit.add_argument("--name")
|
||||
edit.add_argument("--careers-url")
|
||||
edit.add_argument("--note")
|
||||
edit.add_argument("--reason", choices=HAND_REASONS, metavar="REASON",
|
||||
help=f"one of {', '.join(repr(r) for r in HAND_REASONS)}")
|
||||
checked = companies_sub.add_parser(
|
||||
"checked", help="record that its careers page was looked at just now")
|
||||
checked.add_argument("key")
|
||||
remove = companies_sub.add_parser(
|
||||
"remove", help="delete a company with no board on and no open roles")
|
||||
remove.add_argument("key")
|
||||
companies_sub.add_parser(
|
||||
"by-hand", help="the companies checked by hand, never checked first, then the "
|
||||
"longest ago")
|
||||
set_board = companies_sub.add_parser(
|
||||
"set-board", help="attach a board to a company, or replace the one it has")
|
||||
set_board.add_argument("key", help="the company key, e.g. trade-republic")
|
||||
@@ -274,7 +300,15 @@ def run_companies(args: argparse.Namespace) -> int:
|
||||
if args.action == "seed":
|
||||
return seed_companies(store, args.path)
|
||||
if args.action == "add":
|
||||
return add_company(store, args.board, args.name)
|
||||
return add_company(store, args)
|
||||
if args.action == "edit":
|
||||
return edit_company(store, args)
|
||||
if args.action == "checked":
|
||||
return company_checked(store, args.key)
|
||||
if args.action == "remove":
|
||||
return remove_company(store, args.key)
|
||||
if args.action == "by-hand":
|
||||
return list_by_hand(store)
|
||||
if args.action == "set-board":
|
||||
return set_board(store, args.key, args.board)
|
||||
if args.action == "detach":
|
||||
@@ -318,7 +352,25 @@ def discover_company(store: Store, name: str, domain: str, *, add: bool) -> int:
|
||||
return 0
|
||||
|
||||
|
||||
def add_company(store: Store, board: str, name: str) -> int:
|
||||
def add_company(store: Store, args: argparse.Namespace) -> int:
|
||||
"""`app companies add "Acme" [--careers-url URL] [--note TEXT] [--reason
|
||||
REASON]` puts a company with no board on the list checked by hand;
|
||||
`app companies add greenhouse:acme "Acme"` follows it by its board."""
|
||||
if args.second is not None:
|
||||
return add_company_by_board(store, args.first, args.second)
|
||||
from app import jobs
|
||||
|
||||
try:
|
||||
company = jobs.sources.add_by_hand(store, args.first, careers_url=args.careers_url,
|
||||
notes=args.note, hand_reason=args.reason)
|
||||
except ValueError as exc:
|
||||
print(f"companies add: {exc}", file=sys.stderr)
|
||||
return 1
|
||||
print(json.dumps({"key": company.key, "hand_reason": company.hand_reason}))
|
||||
return 0
|
||||
|
||||
|
||||
def add_company_by_board(store: Store, board: str, name: str) -> int:
|
||||
"""`app companies add greenhouse:acme "Acme"`: fetch the board first
|
||||
and refuse if it does not answer or is not a known host. A company that
|
||||
exists gets the board attached or replaced. Port of seedgen's `-add`."""
|
||||
@@ -334,6 +386,69 @@ def add_company(store: Store, board: str, name: str) -> int:
|
||||
return 0
|
||||
|
||||
|
||||
def edit_company(store: Store, args: argparse.Namespace) -> int:
|
||||
"""`app companies edit acme --careers-url https://acme.example/jobs`: only
|
||||
the options given change; see `jobs.sources.edit_company`."""
|
||||
from app import jobs
|
||||
|
||||
given = {"name": args.name, "careers_url": args.careers_url, "notes": args.note,
|
||||
"hand_reason": args.reason}
|
||||
try:
|
||||
company = jobs.sources.edit_company(
|
||||
store, args.key, **{f: v for f, v in given.items() if v is not None})
|
||||
except KeyError:
|
||||
print(f"companies edit: no company {args.key!r}", file=sys.stderr)
|
||||
return 1
|
||||
except ValueError as exc:
|
||||
print(f"companies edit: {exc}", file=sys.stderr)
|
||||
return 1
|
||||
print(json.dumps({"key": company.key, "name": company.name,
|
||||
"careers_url": company.careers_url, "notes": company.notes,
|
||||
"hand_reason": company.hand_reason}))
|
||||
return 0
|
||||
|
||||
|
||||
def company_checked(store: Store, key: str) -> int:
|
||||
"""`app companies checked acme`: its careers page was looked at just now."""
|
||||
if store.company(key) is None:
|
||||
print(f"companies checked: no company {key!r}", file=sys.stderr)
|
||||
return 1
|
||||
company = store.update_company(key, checked_at=store.now())
|
||||
print(json.dumps({"key": key, "checked_at": company.checked_at}))
|
||||
return 0
|
||||
|
||||
|
||||
def remove_company(store: Store, key: str) -> int:
|
||||
"""`app companies remove acme`: refused for a company still read, see
|
||||
`jobs.sources.remove_company`."""
|
||||
from app import jobs
|
||||
|
||||
try:
|
||||
jobs.sources.remove_company(store, key)
|
||||
except KeyError:
|
||||
print(f"companies remove: no company {key!r}", file=sys.stderr)
|
||||
return 1
|
||||
except ValueError as exc:
|
||||
print(f"companies remove: {exc}", file=sys.stderr)
|
||||
return 1
|
||||
print(json.dumps({"key": key, "removed": True}))
|
||||
return 0
|
||||
|
||||
|
||||
def list_by_hand(store: Store) -> int:
|
||||
"""`app companies by-hand`: the companies with no board shown that are not
|
||||
known from a search only, one line each, never checked first and then the
|
||||
longest ago, as the Sources page lists them; see `jobs.sources.by_hand`."""
|
||||
from app import jobs
|
||||
|
||||
rows = jobs.sources.by_hand(store)
|
||||
for c in rows:
|
||||
checked = c.checked_at[:10] or "never"
|
||||
print(f"{c.name:30} {c.hand_reason or '-':8} {checked:10} {c.careers_url}")
|
||||
print(f"{len(rows)} by hand")
|
||||
return 0
|
||||
|
||||
|
||||
def set_board(store: Store, key: str, board: str) -> int:
|
||||
"""`app companies set-board trade-republic greenhouse:traderepublic`:
|
||||
attach the board to an existing company or replace the one it has."""
|
||||
|
||||
Reference in new issue
Block a user