Repository navigation
fix(sync): honor --recent-days and --since for facts and todos - #22
Open
tmoody1973 wants to merge 2 commits into
Open
tmoody1973 wants to merge 2 commits into
tmoody1973 wants to merge 2 commits into
Conversation
Facts and todos were always fetched in full, so --recent-days and --since were silently ignored for them (bee-computer#14). The list endpoints take no date filter, so bound them client-side by created_at and stop paging once a newest-first page reaches the cutoff. Pages that are not newest-first keep paging and are filtered, so results stay complete. Refs bee-computer#14
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.
This is the CLI half of #14. Refs #14.
bee sync --recent-days Nand--sincelimit daily summaries and conversations, but facts and todos are always downloaded in full: every page, every run. The README says that's on purpose, since they're usually small. For the account in #14 it's what breaks sync:/v1/factsreturns a 500 partway through the history, and no flag lets you avoid it.I found #14 while building a hackathon project on top of Bee's data.
This change makes both flags apply to facts and todos too:
created_at.--recent-days 7it never reaches the old pages that fail.--sincetakes the same values as before (epoch ms or av1-cursor). For facts and todos it means "created since," because they don't go through the change feed.One behavior to flag:
facts.mdandtodos.mdare rewritten on every run, so passing either flag on a repeat sync leaves only the matching items in those two files. Daily summaries and conversations still ignore--recent-dayson repeat syncs, as the README describes. I went this way because applying the flag only on first syncs would leave every repeat sync walking the full facts history into the same 500. Happy to change it if you'd rather keep them consistent.The server-side 500s in #14 (
/v1/todos,/v1/daily, and deep/v1/factspages) aren't fixed here. Those need an API change.Testing
sources/commands/sync/index.test.ts: reading the cutoff from both flags, stopping after the first page older than--recent-days,--sinceon todos, pages that aren't newest first, and no flags at all. The first four fail onmain.bun run typecheck,bun run buildandbun test(382 pass, 1 skip, 0 fail;mainis 377 pass) are clean.--recent-days 3wrote 9, all from the last 3 days. Todos: 8 in full, 1 with--recent-days 3. My account fits in one page and doesn't hit the 500, so the early stop is covered by the unit tests, not a live run.Built with Claude Code. The tests and live checks above ran on my machine, against my own Bee account.