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

[KWSearch] Double Confluence parent IDs #9274

Merged
merged 9 commits into from
Dec 12, 2024
15 changes: 15 additions & 0 deletions connectors/src/connectors/confluence/lib/internal_ids.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import {
makeConfluencePageId,
makeConfluenceSpaceId,
} from "@connectors/connectors/confluence/temporal/utils";

enum ConfluenceInternalIdPrefix {
Space = "cspace_",
Page = "cpage_",
Expand Down Expand Up @@ -27,3 +32,13 @@ export function isConfluenceInternalPageId(
): internalId is `${ConfluenceInternalIdPrefix.Page}${string}` {
return internalId.startsWith(ConfluenceInternalIdPrefix.Page);
}

export function convertInternalIdToDocumentId(internalId: string): string {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the intent to merge the functions after the internal id is removed? (aka delete getId fns)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes this is the plan, I think we can do it after all the doubling up and migrating is done

if (isConfluenceInternalPageId(internalId)) {
return makeConfluencePageId(getIdFromConfluenceInternalId(internalId));
}
if (isConfluenceInternalSpaceId(internalId)) {
return makeConfluenceSpaceId(getIdFromConfluenceInternalId(internalId));
}
throw new Error(`Invalid internal ID: ${internalId}`);
}
14 changes: 11 additions & 3 deletions connectors/src/connectors/confluence/temporal/activities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ import {
getConfluencePageParentIds,
getSpaceHierarchy,
} from "@connectors/connectors/confluence/lib/hierarchy";
import { makeConfluenceInternalPageId } from "@connectors/connectors/confluence/lib/internal_ids";
import {
convertInternalIdToDocumentId,
makeConfluenceInternalPageId,
} from "@connectors/connectors/confluence/lib/internal_ids";
import {
makeConfluenceDocumentUrl,
makeConfluencePageId,
Expand Down Expand Up @@ -384,7 +387,8 @@ export async function confluenceCheckAndUpsertPageActivity({
documentUrl,
loggerArgs,
// Parent Ids will be computed after all page imports within the space have been completed.
parents: [makeConfluenceInternalPageId(documentId)],
// TODO(2024-12-11 aubin): we upsert parents x2 (old and new), this is the first step of the backfill plan
parents: [documentId, makeConfluenceInternalPageId(pageId)],
tags,
timestampMs: lastPageVersionCreatedAt.getTime(),
upsertContext: {
Expand Down Expand Up @@ -572,7 +576,11 @@ export async function confluenceUpdatePagesParentIdsActivity(
await updateDocumentParentsField({
dataSourceConfig: dataSourceConfigFromConnector(connector),
documentId: makeConfluencePageId(page.pageId),
parents: parentIds,
// TODO(2024-12-11 aubin): we upsert parents x2 (old and new), this is the first step of the backfill plan
parents: [
...parentIds,
...parentIds.map(convertInternalIdToDocumentId),
],
});
},
{ concurrency: 10 }
Expand Down
4 changes: 4 additions & 0 deletions connectors/src/connectors/confluence/temporal/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ export function makeConfluencePageId(pageId: string) {
return `confluence-page-${pageId}`;
}

export function makeConfluenceSpaceId(spaceId: string) {
return `confluence-space-${spaceId}`;
}

export function makeConfluenceDocumentUrl({
baseUrl,
suffix,
Expand Down
Loading