Skip to content

Commit

Permalink
Review: rename eventCreatedAt to eventTimestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
spastorelli committed Jan 4, 2024
1 parent 693adee commit 3a47e48
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion integrations/github/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ const handleSpaceContentUpdated: EventCallback<
}

await triggerExport(context, spaceInstallation, {
eventCreatedAt: new Date(revision.createdAt),
eventTimestamp: new Date(revision.createdAt),
});
};

Expand Down
16 changes: 8 additions & 8 deletions integrations/github/src/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,16 @@ export async function triggerImport(
updateGitInfo?: boolean;

/**
* The date/time of the event that triggers the import.
* The timestamp of the event that triggers the import.
*
* This is to help ensures that Git sync import and export operations are executed
* in the same order on GitBook and on the remote repository.
*/
eventCreatedAt?: Date;
eventTimestamp?: Date;
} = {}
) {
const { api } = context;
const { force = false, updateGitInfo = false, standalone, eventCreatedAt } = options;
const { force = false, updateGitInfo = false, standalone, eventTimestamp } = options;

const config = getSpaceConfigOrThrow(spaceInstallation);
assertIsDefined(config.branch, { label: 'config.branch' });
Expand All @@ -76,7 +76,7 @@ export async function triggerImport(
repoProjectDirectory: config.projectDirectory,
repoCacheID: config.key,
force,
timestamp: eventCreatedAt && !force ? eventCreatedAt.toISOString() : undefined,
timestamp: eventTimestamp && !force ? eventTimestamp.toISOString() : undefined,
standalone: !!standalone,
...(updateGitInfo ? { gitInfo: { provider: 'github', url: repoURL } } : {}),
});
Expand All @@ -96,16 +96,16 @@ export async function triggerExport(
updateGitInfo?: boolean;

/**
* The date/time of the event that triggers the export.
* The timestamp of the event that triggers the export.
*
* This is to help ensures that Git sync import and export operations are executed
* in the same order on GitBook and on the remote repository.
*/
eventCreatedAt?: Date;
eventTimestamp?: Date;
} = {}
) {
const { api } = context;
const { force = false, updateGitInfo = false, eventCreatedAt } = options;
const { force = false, updateGitInfo = false, eventTimestamp } = options;

const config = getSpaceConfigOrThrow(spaceInstallation);
assertIsDefined(config.branch, { label: 'config.branch' });
Expand All @@ -129,7 +129,7 @@ export async function triggerExport(
repoProjectDirectory: config.projectDirectory,
repoCacheID: config.key,
force,
timestamp: eventCreatedAt && !force ? eventCreatedAt.toISOString() : undefined,
timestamp: eventTimestamp && !force ? eventTimestamp.toISOString() : undefined,
commitMessage: getCommitMessageForRevision(config, revision),
...(updateGitInfo ? { gitInfo: { provider: 'github', url: repoURL } } : {}),
});
Expand Down
4 changes: 2 additions & 2 deletions integrations/github/src/webhooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export async function handlePushEvent(
});

await triggerImport(context, spaceInstallation, {
eventCreatedAt: payload.head_commit?.timestamp
eventTimestamp: payload.head_commit?.timestamp
? new Date(payload.head_commit?.timestamp)
: undefined,
});
Expand Down Expand Up @@ -151,7 +151,7 @@ export async function handlePullRequestEvents(
standalone: {
ref: headRef,
},
eventCreatedAt:
eventTimestamp:
payload.action === 'opened'
? new Date(payload.pull_request.created_at)
: new Date(payload.pull_request.updated_at),
Expand Down
2 changes: 1 addition & 1 deletion integrations/gitlab/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ const handleSpaceContentUpdated: EventCallback<
}

await triggerExport(context, spaceInstallation, {
eventCreatedAt: new Date(revision.createdAt),
eventTimestamp: new Date(revision.createdAt),
});
};

Expand Down
16 changes: 8 additions & 8 deletions integrations/gitlab/src/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,16 @@ export async function triggerImport(
updateGitInfo?: boolean;

/**
* The date/time of the event that triggers the import.
* The timestamp of the event that triggers the import.
*
* This is to help ensures that Git sync import and export operations are executed
* in the same order on GitBook and on the remote repository.
*/
eventCreatedAt?: Date;
eventTimestamp?: Date;
} = {}
) {
const { api } = context;
const { force = false, updateGitInfo = false, standalone, eventCreatedAt } = options;
const { force = false, updateGitInfo = false, standalone, eventTimestamp } = options;

const config = getSpaceConfigOrThrow(spaceInstallation);
assertIsDefined(config.branch, { label: 'config.branch' });
Expand All @@ -76,7 +76,7 @@ export async function triggerImport(
repoProjectDirectory: config.projectDirectory,
repoCacheID: config.key,
force,
timestamp: eventCreatedAt && !force ? eventCreatedAt.toISOString() : undefined,
timestamp: eventTimestamp && !force ? eventTimestamp.toISOString() : undefined,
standalone: !!standalone,
...(updateGitInfo ? { gitInfo: { provider: 'gitlab', url: repoURL } } : {}),
});
Expand All @@ -96,16 +96,16 @@ export async function triggerExport(
updateGitInfo?: boolean;

/**
* The date/time of the event that triggers the export.
* The timestamp of the event that triggers the export.
*
* This is to help ensures that Git sync import and export operations are executed
* in the same order on GitBook and on the remote repository.
*/
eventCreatedAt?: Date;
eventTimestamp?: Date;
} = {}
) {
const { api } = context;
const { force = false, updateGitInfo = false, eventCreatedAt } = options;
const { force = false, updateGitInfo = false, eventTimestamp } = options;

const config = getSpaceConfigOrThrow(spaceInstallation);
assertIsDefined(config.branch, { label: 'config.branch' });
Expand All @@ -129,7 +129,7 @@ export async function triggerExport(
repoProjectDirectory: config.projectDirectory,
repoCacheID: config.key,
force,
timestamp: eventCreatedAt && !force ? eventCreatedAt.toISOString() : undefined,
timestamp: eventTimestamp && !force ? eventTimestamp.toISOString() : undefined,
commitMessage: getCommitMessageForRevision(config, revision),
...(updateGitInfo ? { gitInfo: { provider: 'gitlab', url: repoURL } } : {}),
});
Expand Down
4 changes: 2 additions & 2 deletions integrations/gitlab/src/webhooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export async function handlePushEvent(context: GitLabRuntimeContext, payload: Gi
});

await triggerImport(context, spaceInstallation, {
eventCreatedAt: headCommit ? new Date(headCommit.timestamp) : undefined,
eventTimestamp: headCommit ? new Date(headCommit.timestamp) : undefined,
});
} catch (error) {
logger.error(
Expand Down Expand Up @@ -194,7 +194,7 @@ export async function handleMergeRequestEvent(
standalone: {
ref: sourceRef,
},
eventCreatedAt:
eventTimestamp:
payload.object_attributes.action === 'open'
? new Date(payload.object_attributes.created_at)
: new Date(payload.object_attributes.updated_at),
Expand Down

0 comments on commit 3a47e48

Please sign in to comment.