Skip to content

Commit

Permalink
dispatch256 with index
Browse files Browse the repository at this point in the history
  • Loading branch information
simon300000 committed Sep 7, 2023
1 parent c0838f4 commit ac82a14
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,9 @@ router.post('/dispatch', ctx => {
ctx.body = { url: dispatch() }
})

router.post('/dispatch256', ctx => {
ctx.body = { urls: dispatch256() }
router.post('/dispatch256', koaBody(), ctx => {
const { i } = ctx.request.body
ctx.body = { urls: dispatch256(i) }
})

router.post('/receipt', koaBody(), ctx => {
Expand Down
2 changes: 1 addition & 1 deletion api/dispatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const fetch = async (url: string) => {
}

export const dispatch = () => jobs[Math.floor(Math.random() * jobs.length)]?.url
export const dispatch256 = () => jobs.filter((_, i) => i < 256).map(job => job.url)
export const dispatch256 = (i = 0) => jobs.filter((_, i) => i >= i * 256).filter((_, i) => i < 256).map(job => job.url)

export const receipt = (url: string, data: any) => {
if (data.code === 0) {
Expand Down

0 comments on commit ac82a14

Please sign in to comment.