Skip to content

Commit

Permalink
chore: better name for ScheduledJob migration
Browse files Browse the repository at this point in the history
  - also: removed unecessary transform from earlier revision
  • Loading branch information
jordanh committed Mar 2, 2024
1 parent 2571c9e commit d58e5ea
Showing 1 changed file with 6 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,14 @@ export async function up() {
{table: 'ScheduledJob'}
)

const transformRethinkRow = (row: any) => {
const {runAt, type, orgId, meetingId} = row
return {
runAt,
type,
orgId,
meetingId
}
}

const getNextData = async (leftBoundCursor: Date | undefined) => {
const startAt = leftBoundCursor || r.minval
const nextBatch = (
await r
.table('ScheduledJob')
.between(startAt, r.maxval, {index: 'runAt', leftBound: 'open'})
.orderBy({index: 'runAt'})
.limit(batchSize)
.run()
).map(transformRethinkRow)
const nextBatch = await r
.table('ScheduledJob')
.between(startAt, r.maxval, {index: 'runAt', leftBound: 'open'})
.orderBy({index: 'runAt'})
.limit(batchSize)
.run()
if (nextBatch.length === 0) return null
if (nextBatch.length < batchSize) return nextBatch
const lastItem = nextBatch.pop()
Expand Down

0 comments on commit d58e5ea

Please sign in to comment.