mirror of
https://github.com/whekin/household-bot.git
synced 2026-04-01 00:14:03 +00:00
feat(bot): add self-hosted scheduled dispatch support
Co-authored-by: claw <stanislavkalishin+claw@gmail.com>
This commit is contained in:
@@ -68,6 +68,19 @@ class ScheduledDispatchRepositoryStub implements ScheduledDispatchRepository {
|
||||
return [...this.dispatches.values()].filter((dispatch) => dispatch.householdId === householdId)
|
||||
}
|
||||
|
||||
async listDueScheduledDispatches(input: {
|
||||
dueBefore: Temporal.Instant
|
||||
provider?: ScheduledDispatchRecord['provider']
|
||||
limit: number
|
||||
}): Promise<readonly ScheduledDispatchRecord[]> {
|
||||
return [...this.dispatches.values()]
|
||||
.filter((dispatch) => dispatch.status === 'scheduled')
|
||||
.filter((dispatch) => dispatch.dueAt.epochMilliseconds <= input.dueBefore.epochMilliseconds)
|
||||
.filter((dispatch) => (input.provider ? dispatch.provider === input.provider : true))
|
||||
.sort((left, right) => left.dueAt.epochMilliseconds - right.dueAt.epochMilliseconds)
|
||||
.slice(0, input.limit)
|
||||
}
|
||||
|
||||
async updateScheduledDispatch(input: {
|
||||
dispatchId: string
|
||||
dueAt?: Temporal.Instant
|
||||
|
||||
Reference in New Issue
Block a user