Join company records client-side for --expand company - #11
Merged
Conversation
`--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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #6. Stacked on #10 (review the last commit only).
Why the API can't do this
--expand companywas a no-op becauseexpandisn't in the events allow-list, sotoParamsdropped it before the request. Forwarding it instead is not an option — the API rejects it outright:So the join has to happen in the CLI.
Change
splitExpandpeelscompanyoff the flag; everything else goes to the API untouched (--expand event,companystill sendsexpand=event).joinCompaniescollects the distinctcompanyIds, fetches them from/companiesin batches of 100, and fills inrow["company"].Details worth knowing:
companyobject are skipped, so the join disables itself if Quartr ever ships server-side expansion.--allit runs once over the accumulated rows, not once per page.get.events get <id> --expand companywas silently dropping the flag too./companieslookup printswarning: --expand company: ...to stderr and still prints the rows. Losing the whole result because the decoration failed would be worse.--expand companyoncompanies(redundant) or ondocument-types(nocompanyIdon the rows) is a usage error, exit 2.company.nameandcompany.countryare now in the default column set. That's deliberate: the ticker collision in #5 is invisible without them.Live behaviour
One
--tickers ACArequest, two companies, now visibly interleaved.Tests
Join with deduped ids and exactly one
/companiesround-trip;expand=eventpreserved on the wire whilecompanyis stripped; usage errors for both unsupported resources; and a 403 from/companiesleaving stdout intact with a warning on stderr.🤖 Generated with Claude Code