const getAllChallenges = Effect.fn(span("getAllChallenges"))(
function*(ids: ReadonlyArray<ChallengeId>) {
return yield* Effect.forEach(
ids,
(id) =>
Effect.zip(
GetChallengeWithCheckInSchedule.execute(id),
GetChallengeRequirements.execute(id),
{ concurrent: true, batching: true }
).pipe(
Effect.andThen(([challengeOption, reqs]) =>
Option.map(challengeOption, (challenge) =>
ChallengeFull.make({
...challenge,
requirements: reqs,
defaultCheckInSchedule: challenge.schedule
}))
)
),
{ concurrency: 10, batching: true }
)
}
)
const getAllChallenges = Effect.fn(span("getAllChallenges"))(
function*(ids: ReadonlyArray<ChallengeId>) {
return yield* Effect.forEach(
ids,
(id) =>
Effect.zip(
GetChallengeWithCheckInSchedule.execute(id),
GetChallengeRequirements.execute(id),
{ concurrent: true, batching: true }
).pipe(
Effect.andThen(([challengeOption, reqs]) =>
Option.map(challengeOption, (challenge) =>
ChallengeFull.make({
...challenge,
requirements: reqs,
defaultCheckInSchedule: challenge.schedule
}))
)
),
{ concurrency: 10, batching: true }
)
}
)