Skip to content

Commit 9935085

Browse files
committed
update
1 parent d73168f commit 9935085

File tree

1 file changed

+40
-42
lines changed

1 file changed

+40
-42
lines changed

packages/crawler/observables.ts

Lines changed: 40 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -52,45 +52,43 @@ const getGithubPage$ = (subUrl: string) =>
5252
});
5353
});
5454

55-
export const getGithubData$ = () =>
56-
forkJoin([
57-
category$,
58-
getGithub$().pipe(
59-
switchMap((x: any) => {
60-
const bar = new ProgressBar('complete :gitIndex of :total: :gtnm', {
61-
total: x.length,
62-
});
63-
return from<Observable<GitSchema>>(x).pipe(
64-
map((v: GitSchema, k: number) => [v, k]),
65-
concatMap(([v, gitIndex]: any[]) =>
66-
getGithubPage$(v.github).pipe(
67-
tap(() => {
68-
bar.tick({ gitIndex: gitIndex + 1, gtnm: v.github });
69-
}),
70-
retry(retryAttempt),
71-
map((v) => parseExtractGithub(v as string)),
72-
catchError(
73-
(): Observable<GitParseResult> =>
74-
of({
75-
star: -1,
76-
lastUpdate: '',
77-
})
78-
),
79-
map(
80-
(parseRes: GitParseResult): GitSchema =>
81-
mergeResult(v, parseRes)
82-
),
83-
tap(({ star, github }) => {
84-
if (star < 0) {
85-
// eslint-disable-next-line no-console
86-
console.log(`\n - failed on ${github}`);
87-
}
88-
}),
89-
delay(crawlerStepDelay)
90-
)
91-
),
92-
toArray()
93-
);
94-
})
95-
),
96-
]);
55+
const getGithubList$ = () =>
56+
getGithub$().pipe(
57+
switchMap((x: any) => {
58+
const bar = new ProgressBar('complete :gitIndex of :total: :gtnm', {
59+
total: x.length,
60+
});
61+
return from<Observable<GitSchema>>(x).pipe(
62+
map((v: GitSchema, k: number) => [v, k]),
63+
concatMap(([v, gitIndex]: any[]) =>
64+
getGithubPage$(v.github).pipe(
65+
tap(() => {
66+
bar.tick({ gitIndex: gitIndex + 1, gtnm: v.github });
67+
}),
68+
retry(retryAttempt),
69+
map((v) => parseExtractGithub(v as string)),
70+
catchError(
71+
(): Observable<GitParseResult> =>
72+
of({
73+
star: -1,
74+
lastUpdate: '',
75+
})
76+
),
77+
map(
78+
(parseRes: GitParseResult): GitSchema => mergeResult(v, parseRes)
79+
),
80+
tap(({ star, github }) => {
81+
if (star < 0) {
82+
// eslint-disable-next-line no-console
83+
console.log(`\n - failed on ${github}`);
84+
}
85+
}),
86+
delay(crawlerStepDelay)
87+
)
88+
),
89+
toArray()
90+
);
91+
})
92+
);
93+
94+
export const getGithubData$ = () => forkJoin([category$, getGithubList$()]);

0 commit comments

Comments
 (0)