Skip to content

Commit

Permalink
Limit concurrency when searching for comics
Browse files Browse the repository at this point in the history
  • Loading branch information
floogulinc committed Feb 3, 2021
1 parent 0a11b27 commit 8134b03
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/app/comics.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Injectable } from '@angular/core';
import { HydrusFilesService } from './hydrus-files.service';
import { SearchService } from './search.service';
import { forkJoin, from } from 'rxjs';
import { map, switchMap, filter, mergeMap, toArray, delay, concatMap, tap, reduce, distinct } from 'rxjs/operators';
import { map, switchMap, filter, mergeMap, toArray, delay, concatMap, tap, reduce, distinct, retry } from 'rxjs/operators';
import { TagUtils } from './tag-utils';
import { HydrusFile } from './hydrus-file';

Expand All @@ -13,6 +13,7 @@ export interface FlatComic {
numFiles: number;
}

const CONCURRENCY = 8;

@Injectable({
providedIn: 'root'
Expand Down Expand Up @@ -94,7 +95,7 @@ export class ComicsService {
mergeMap(tag => this.searchService.searchFiles([tag]).pipe(
tap(() => this.updateLoading(tag)),
map(files => ({tag, files}))
)))
), CONCURRENCY))
.pipe(
filter(({files}) => files.length > 3),
distinct(({files}) => files.toString()),
Expand All @@ -115,7 +116,7 @@ export class ComicsService {
coverFile: this.findCoverFile(fileMetadata),
numFiles: fileMetadata.length
}))
)),
), CONCURRENCY),
reduce((acc, val) => acc.concat([{tag: val.tag, coverFile: val.coverFile, numFiles: val.numFiles}, ...val.volumes.map(v => ({
tag: val.tag,
volume: v.tag,
Expand Down

0 comments on commit 8134b03

Please sign in to comment.