Skip to content

Commit

Permalink
frontend:
Browse files Browse the repository at this point in the history
- follow up to #969, fixes crawl workflows by using crawl-specific endpoint and merging results
  • Loading branch information
ikreymer committed Jul 10, 2023
1 parent f366083 commit cfea80f
Showing 1 changed file with 13 additions and 23 deletions.
36 changes: 13 additions & 23 deletions frontend/src/pages/org/collection-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1332,26 +1332,6 @@ export class CollectionEditor extends LiteElement {
}
}

private async getCrawlsAndUploads(
params: Partial<{
collectionId?: string;
state: CrawlState[];
}> &
APIPaginationQuery &
APISortQuery
): Promise<APIPaginatedList> {
const query = queryString.stringify({
state: "complete",
...params,
});
const data: APIPaginatedList = await this.apiFetch(
`/orgs/${this.orgId}/all-crawls?${query}`,
this.authState!
);

return data;
}

private async getUploads(
params: Partial<{
collectionId?: string;
Expand All @@ -1376,23 +1356,33 @@ export class CollectionEditor extends LiteElement {
if (!this.collectionId) return;

try {
const { items: crawls } = await this.getCrawlsAndUploads({
const { items: crawls } = await this.getCrawls({
collectionId: this.collectionId,
sortBy: "finished",
pageSize: WORKFLOW_CRAWL_LIMIT,
});

const { items: uploads } = await this.getUploads({
collectionId: this.collectionId,
sortBy: "finished",
pageSize: WORKFLOW_CRAWL_LIMIT,
});

const crawlsAndUploads = [...crawls, ...uploads];

this.selectedCrawls = mergeDeep(
this.selectedCrawls,
crawls.reduce(
crawlsAndUploads.reduce(
(acc, crawl) => ({
...acc,
[crawl.id]: crawl,
}),
{}
)
);

// TODO remove omit once API removes errors
this.collectionCrawls = crawls.map(omit("errors")) as Crawl[];
this.collectionCrawls = crawlsAndUploads.map(omit("errors")) as Crawl[];
// Store crawl IDs to compare later
this.savedCollectionCrawlIds = this.collectionCrawls.map(({ id }) => id);
} catch {
Expand Down

0 comments on commit cfea80f

Please sign in to comment.