Repository navigation
feat: recurring expenses API and scheduler - #56
Merged
Merged
Conversation
… and harden the scheduler
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.
POST/PUT /api/expensestakerepeat: {unit: week|month|year, every}ornull(only those four frequencies are accepted for now). A newrecurring_seriesrow holds the schedule (anchor date, next run, active); the expense gets a nullableseries_id. The series' latest expense, by creation order, is what the next one copies.ExpenseResponseaddsrepeat {unit, every, nextOn, active}andseries {latestId, isLatest}; activity items addrecurring.app:recurring:run, also run hourly through symfony/scheduler. Each run creates every occurrence that's due, including ones missed while nothing ran, each on its own date, copying payee, title, amount, currency, category, split and description (not comments). Each series runs in its own transaction with a row lock, so overlapping runs create nothing twice; a series that fails is logged and retried on the next run.schedulerservice on the php image todeploy/compose.yamland the devcompose.yaml. It skips the migrating entrypoint, waits forphpto be healthy, runs the job once on start, then consumes the schedule. The devphpservice gets the same healthcheck as the deploy. The default bus pings the DB connection before handling, since the worker idles between ticks.DEPLOYMENT.mdcovers the service, a host-cron alternative and rolling back to v0.1.0.Proved with unit tests for the schedule, integration tests for the runner (catch-up, idempotency, stopped and failing series) and API tests, plus the dev stack: a monthly expense dated 10 Aug came back with next 10 Dec, and after rewinding its next run to 10 Sep the scheduler container created the 10 Sep, 10 Oct and 10 Nov copies. The prod image's scheduler entrypoint ran against the dev DB without errors.