Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix [sc-8784]: Fix sitemap connector #12

Merged
merged 2 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { from, map, Observable, of, switchMap } from 'rxjs';
import { ConnectorParameters, FileStatus, IConnector, Link, SearchResults, SyncItem } from '../../domain/connector';
import { SourceConnectorDefinition } from '../factory';
import cheerio from 'cheerio';
import * as cheerio from 'cheerio';

interface SiteMapModel {
loc: string;
Expand All @@ -10,7 +10,7 @@ interface SiteMapModel {

async function fetchSitemap(url: string): Promise<string> {
const response = await fetch(url);
// todo: control whether it is zipped or plain
// TODO: control whether it is zipped or plain
return response.text();
}

Expand Down Expand Up @@ -53,11 +53,8 @@ class SitemapImpl implements IConnector {
this.params = params;
}

areParametersValid(params: ConnectorParameters) {
if (!params?.sitemap) {
return false;
}
return true;
areParametersValid(params: ConnectorParameters): boolean {
return !!params?.sitemap;
}

getParameters(): ConnectorParameters {
Expand Down
17 changes: 10 additions & 7 deletions server/src/logic/sync/domain/sync.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,17 @@ export class SyncEntity {
const foldersToSyncUpdated: SyncItem[] = (this.foldersToSync ?? []).filter(
(folder) => folder.status === FileStatus.UPLOADED,
);
const getFilesFoldersUpdated = this.sourceConnector!.getLastModified(
this.lastSyncGMT || '2000-01-01T00:00:00.000Z',
foldersToSyncUpdated,
);
const getFilesFolderPending = this.sourceConnector!.getFilesFromFolders(foldersToSyncPending);
const getFilesFoldersUpdated =
foldersToSyncUpdated.length > 0
? this.sourceConnector!.getLastModified(this.lastSyncGMT || '2000-01-01T00:00:00.000Z', foldersToSyncUpdated)
: of({ items: [] });

const getFilesFolderPending =
foldersToSyncPending.length > 0
? this.sourceConnector!.getFilesFromFolders(foldersToSyncPending)
: of({ items: [] });
return forkJoin([getFilesFoldersUpdated, getFilesFolderPending]).pipe(
map((results) => {
const [updated, pending] = results;
map(([updated, pending]) => {
return { success: true, results: [...updated.items, ...pending.items] };
}),
catchError((err) => {
Expand Down
Loading