From fd15c1137cd1d9d64be11c6033aed4343407f8a9 Mon Sep 17 00:00:00 2001 From: Matthew Tovbin Date: Wed, 13 Sep 2023 09:20:07 -0700 Subject: [PATCH] Truncate vcs_PullRequestComment comments to 1000 chars --- .../src/converters/azure-repos/commits.ts | 4 ++-- .../src/converters/azure-repos/common.ts | 2 ++ .../src/converters/azure-repos/pull_requests.ts | 4 ++-- .../converters/bitbucket-server/pull_request_activities.ts | 6 +++++- .../src/converters/bitbucket/pull_request_activities.ts | 5 ++++- .../src/converters/github/review_comments.ts | 5 ++++- 6 files changed, 19 insertions(+), 7 deletions(-) diff --git a/destinations/airbyte-faros-destination/src/converters/azure-repos/commits.ts b/destinations/airbyte-faros-destination/src/converters/azure-repos/commits.ts index ffdc98789..f666ddc73 100644 --- a/destinations/airbyte-faros-destination/src/converters/azure-repos/commits.ts +++ b/destinations/airbyte-faros-destination/src/converters/azure-repos/commits.ts @@ -2,7 +2,7 @@ import {AirbyteRecord} from 'faros-airbyte-cdk'; import {Utils} from 'faros-js-client'; import {DestinationModel, DestinationRecord} from '../converter'; -import {AzureReposConverter} from './common'; +import {AzureReposConverter, MAX_DESCRIPTION_LENGTH} from './common'; import {Commit} from './models'; export class Commits extends AzureReposConverter { @@ -34,7 +34,7 @@ export class Commits extends AzureReposConverter { record: { sha: commitItem.commitId, uid: commitItem.commitId, - message: commitItem.comment, + message: commitItem.comment?.substring(0, MAX_DESCRIPTION_LENGTH), htmlUrl: commitItem.remoteUrl, createdAt: Utils.toDate(commitItem.committer?.date), author: {uid: commitItem.author?.email, source}, diff --git a/destinations/airbyte-faros-destination/src/converters/azure-repos/common.ts b/destinations/airbyte-faros-destination/src/converters/azure-repos/common.ts index a93ecc788..bc9d1ff58 100644 --- a/destinations/airbyte-faros-destination/src/converters/azure-repos/common.ts +++ b/destinations/airbyte-faros-destination/src/converters/azure-repos/common.ts @@ -9,6 +9,8 @@ import { PullRequestStateCategory, } from './models'; +export const MAX_DESCRIPTION_LENGTH = 1000; + export type ApplicationMapping = Record< string, {name: string; platform?: string} diff --git a/destinations/airbyte-faros-destination/src/converters/azure-repos/pull_requests.ts b/destinations/airbyte-faros-destination/src/converters/azure-repos/pull_requests.ts index 5a09e5ae5..53cf2843f 100644 --- a/destinations/airbyte-faros-destination/src/converters/azure-repos/pull_requests.ts +++ b/destinations/airbyte-faros-destination/src/converters/azure-repos/pull_requests.ts @@ -2,7 +2,7 @@ import {AirbyteRecord} from 'faros-airbyte-cdk'; import {Utils} from 'faros-js-client'; import {DestinationModel, DestinationRecord} from '../converter'; -import {AzureReposConverter} from './common'; +import {AzureReposConverter, MAX_DESCRIPTION_LENGTH} from './common'; import {PullRequest} from './models'; export class PullRequests extends AzureReposConverter { @@ -43,7 +43,7 @@ export class PullRequests extends AzureReposConverter { record: { number: comment.id, uid: comment.id.toString(), - comment: comment.content, + comment: comment.content?.substring(0, MAX_DESCRIPTION_LENGTH), createdAt: Utils.toDate(comment.publishedDate), updatedAt: Utils.toDate(comment.lastUpdatedDate), author: {uid: comment.author.uniqueName, source}, diff --git a/destinations/airbyte-faros-destination/src/converters/bitbucket-server/pull_request_activities.ts b/destinations/airbyte-faros-destination/src/converters/bitbucket-server/pull_request_activities.ts index c4dea1ec4..a1799d46e 100644 --- a/destinations/airbyte-faros-destination/src/converters/bitbucket-server/pull_request_activities.ts +++ b/destinations/airbyte-faros-destination/src/converters/bitbucket-server/pull_request_activities.ts @@ -7,6 +7,7 @@ import { } from 'faros-airbyte-common/bitbucket-server'; import {Utils} from 'faros-js-client'; +import {MAX_DESCRIPTION_LENGTH} from '../azure-repos/common'; import {DestinationModel, DestinationRecord} from '../converter'; import {BitbucketServerConverter} from './common'; @@ -42,7 +43,10 @@ export class PullRequestActivities extends BitbucketServerConverter { number: id, uid: id.toString(), pullRequest, - comment: activity.comment.text, + comment: activity?.comment?.text?.substring( + 0, + MAX_DESCRIPTION_LENGTH + ), createdAt: Utils.toDate(activity.comment.createdDate), updatedAt: Utils.toDate(activity.comment.updatedDate), author, diff --git a/destinations/airbyte-faros-destination/src/converters/bitbucket/pull_request_activities.ts b/destinations/airbyte-faros-destination/src/converters/bitbucket/pull_request_activities.ts index acc9c3ecd..b2d699060 100644 --- a/destinations/airbyte-faros-destination/src/converters/bitbucket/pull_request_activities.ts +++ b/destinations/airbyte-faros-destination/src/converters/bitbucket/pull_request_activities.ts @@ -91,7 +91,10 @@ export class PullRequestActivities extends BitbucketConverter { record: { number: id, uid: id.toString(), - comment: change?.content?.raw, + comment: change?.content?.raw?.substring( + 0, + BitbucketCommon.MAX_DESCRIPTION_LENGTH + ), createdAt: Utils.toDate(change?.created_on), updatedAt: Utils.toDate(change?.updated_on), author: reviewer, diff --git a/destinations/airbyte-faros-destination/src/converters/github/review_comments.ts b/destinations/airbyte-faros-destination/src/converters/github/review_comments.ts index 9c48cd204..55897ea15 100644 --- a/destinations/airbyte-faros-destination/src/converters/github/review_comments.ts +++ b/destinations/airbyte-faros-destination/src/converters/github/review_comments.ts @@ -34,7 +34,10 @@ export class ReviewComments extends GitHubConverter { record: { number: comment.id, uid: comment.id.toString(), - comment: comment.body, + comment: comment?.body?.substring( + 0, + GitHubCommon.MAX_DESCRIPTION_LENGTH + ), createdAt: Utils.toDate(comment.created_at), updatedAt: Utils.toDate(comment.updated_at), author,