Skip to content

Commit

Permalink
connectors: add standardized presentation of author and lastEditor (#…
Browse files Browse the repository at this point in the history
…3160)

* connectors: add standardized presentation of author and lastEditor

* optim
  • Loading branch information
spolu authored Jan 11, 2024
1 parent 035ba59 commit 2337e1c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,7 @@ async function syncOneFile(
title: file.name,
updatedAt: file.updatedAtMs ? new Date(file.updatedAtMs) : undefined,
createdAt: file.createdAtMs ? new Date(file.createdAtMs) : undefined,
lastEditor: file.lastEditor ? file.lastEditor.displayName : undefined,
content: documentContent
? { prefix: null, content: documentContent, sections: [] }
: null,
Expand Down
2 changes: 2 additions & 0 deletions connectors/src/connectors/notion/temporal/activities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1757,6 +1757,8 @@ export async function renderAndUpsertPageFromCache({
title: title ?? null,
createdAt: createdAt,
updatedAt: updatedAt,
author,
lastEditor,
content: { prefix: null, content: renderedPage, sections: [] },
});

Expand Down
14 changes: 14 additions & 0 deletions connectors/src/lib/data_sources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,11 +323,15 @@ export function renderDocumentTitleAndContent({
title,
createdAt,
updatedAt,
author,
lastEditor,
content,
}: {
title: string | null;
createdAt?: Date;
updatedAt?: Date;
author?: string;
lastEditor?: string;
content: CoreAPIDataSourceDocumentSection | null;
}): CoreAPIDataSourceDocumentSection {
if (title && title.trim()) {
Expand All @@ -342,6 +346,16 @@ export function renderDocumentTitleAndContent({
if (updatedAt) {
c.prefix += `$updatedAt: ${updatedAt.toISOString()}\n`;
}
if (author && lastEditor && author === lastEditor) {
c.prefix += `$author: ${author}\n`;
} else {
if (author) {
c.prefix += `$author: ${author}\n`;
}
if (lastEditor) {
c.prefix += `$lastEditor: ${lastEditor}\n`;
}
}
if (content) {
c.sections.push(content);
}
Expand Down

0 comments on commit 2337e1c

Please sign in to comment.