Switch to split than aperture
This commit is contained in:
@@ -4,7 +4,7 @@ import Redis from 'ioredis'
|
|||||||
import { InjectRedis } from '@liaoliaots/nestjs-redis';
|
import { InjectRedis } from '@liaoliaots/nestjs-redis';
|
||||||
import { CACHE_MANAGER } from '@nestjs/cache-manager';
|
import { CACHE_MANAGER } from '@nestjs/cache-manager';
|
||||||
import { Cache } from 'cache-manager';
|
import { Cache } from 'cache-manager';
|
||||||
import { aperture } from 'ramda';
|
import { aperture, splitEvery } from 'ramda';
|
||||||
|
|
||||||
export interface JobMetadata {
|
export interface JobMetadata {
|
||||||
name: string;
|
name: string;
|
||||||
@@ -110,8 +110,8 @@ export class JobsService {
|
|||||||
|
|
||||||
|
|
||||||
async addItemsToJob(jobName: string, items: string[]) {
|
async addItemsToJob(jobName: string, items: string[]) {
|
||||||
const apertureSize = 100
|
const splitSize = 500
|
||||||
for (const itemSubset of (items.length > apertureSize ? aperture(apertureSize, items) : [items])) {
|
for (const itemSubset of (items.length > splitSize ? splitEvery(splitSize, items) : [items])) {
|
||||||
await this.redis.rpush(this.todoListNameBuilder(jobName), ...itemSubset);
|
await this.redis.rpush(this.todoListNameBuilder(jobName), ...itemSubset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user