Skip to content

Join company records client-side for --expand company - #11

Merged
arcaputo3 merged 1 commit into
gh-4-sort-by-loud-failurefrom
gh-6-expand-company-join
Aug 5, 2026
Merged

Join company records client-side for --expand company#11
arcaputo3 merged 1 commit into
gh-4-sort-by-loud-failurefrom
gh-6-expand-company-join

Conversation

@arcaputo3

Copy link
Copy Markdown
Contributor

Closes #6. Stacked on #10 (review the last commit only).

Why the API can't do this

--expand company was a no-op because expand isn't in the events allow-list, so toParams dropped it before the request. Forwarding it instead is not an option — the API rejects it outright:

GET /events?expand=company
400  property expand should not exist

GET /documents/transcripts?expand=company
400  each value in expand must be one of the following values: event

So the join has to happen in the CLI.

Change

splitExpand peels company off the flag; everything else goes to the API untouched (--expand event,company still sends expand=event). joinCompanies collects the distinct companyIds, fetches them from /companies in batches of 100, and fills in row["company"].

Details worth knowing:

  • Idempotent. Rows that already embed a company object are skipped, so the join disables itself if Quartr ever ships server-side expansion.
  • One join per command. Under --all it runs once over the accumulated rows, not once per page.
  • Also covers get. events get <id> --expand company was silently dropping the flag too.
  • Non-fatal. A failed /companies lookup prints warning: --expand company: ... to stderr and still prints the rows. Losing the whole result because the decoration failed would be worse.
  • No silent no-ops left. --expand company on companies (redundant) or on document-types (no companyId on the rows) is a usage error, exit 2.

company.name and company.country are now in the default column set. That's deliberate: the ticker collision in #5 is invisible without them.

Live behaviour

$ quartr events list --tickers ACA --limit 6 --expand company \
    --fields id,date,title,companyId,company.name,company.country
id     date                      title              companyId  company.name          company.country
243    2021-08-05T00:00:00.000Z  Q2 2021            3694       Arcosa Inc            US
10115  2021-11-04T00:00:00.000Z  Q3 2021            3694       Arcosa Inc            US
15251  2022-02-24T13:11:02.000Z  Q4 2021            3694       Arcosa Inc            US
20230  2022-04-29T16:56:01.000Z  Q1 2022            3694       Arcosa Inc            US
22156  2022-05-05T16:50:34.000Z  Q1 2022            12301      Crédit Agricole S.A.  FR
24456  2022-06-22T10:26:00.000Z  Investor Day 2022  12301      Crédit Agricole S.A.  FR

One --tickers ACA request, two companies, now visibly interleaved.

Tests

Join with deduped ids and exactly one /companies round-trip; expand=event preserved on the wire while company is stripped; usage errors for both unsupported resources; and a 403 from /companies leaving stdout intact with a warning on stderr.

🤖 Generated with Claude Code

`--expand company` was a silent no-op: `expand` is not in the events
allow-list, so toParams dropped it and rows came back with a bare companyId.
Forwarding it is not an option either — the API rejects it:

  /events?expand=company            400 property expand should not exist
  /documents/transcripts?expand=…   400 each value in expand must be one of
                                        the following values: event

So do the join here. splitExpand peels "company" off the flag, the rest goes
to the API unchanged, and joinCompanies batch-fetches the distinct companyIds
(100 per request) and fills in row["company"]. Rows that already embed a
company object are skipped, so this turns itself off if Quartr ever adds
server-side expansion.

Applies to list, get, and --all (one join across every page). A failed
/companies lookup warns on stderr and leaves the rows unexpanded rather than
losing the data the user already paid for. --expand company on a resource
whose rows have no companyId is a usage error instead of a quiet no-op.

company.name and company.country join the default column set — the ticker
collision in #5 is invisible without them.

Closes #6

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@arcaputo3
arcaputo3 merged commit ad694a1 into main Aug 5, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

events list --expand company does not inline company names (bare companyId only)

1 participant