Skip to content

Commit 3444c79

Browse files
authored
Merge branch 'main' into chore/crowd-dev-devx
2 parents 3c3ccb4 + 09ccc0c commit 3444c79

14 files changed

Lines changed: 346 additions & 157 deletions

File tree

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-- Revert: Drop description column from activityTypes table
2+
-- This reverts migration V1759325136__add_description_to_activity_types.sql
3+
4+
ALTER TABLE "activityTypes" DROP COLUMN description;
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
-- Add description column to activityTypes table
2+
ALTER TABLE "activityTypes" ADD COLUMN description TEXT;
3+
4+
-- Delete changeset-new activity type
5+
DELETE FROM "activityTypes" WHERE "activityType" = 'changeset-new' AND platform = 'gerrit';
6+
7+
-- Update descriptions for existing activity types
8+
9+
-- Confluence platform
10+
UPDATE "activityTypes" SET description = 'Added file attachment to a Confluence page or blog post' WHERE "activityType" = 'attachment' AND platform = 'confluence';
11+
UPDATE "activityTypes" SET description = 'Created file attachment in a Confluence page or blog post' WHERE "activityType" = 'attachment-created' AND platform = 'confluence';
12+
UPDATE "activityTypes" SET description = 'Published a new Confluence blog post' WHERE "activityType" = 'blogpost-created' AND platform = 'confluence';
13+
UPDATE "activityTypes" SET description = 'Updated an existing Confluence blog post' WHERE "activityType" = 'blogpost-updated' AND platform = 'confluence';
14+
UPDATE "activityTypes" SET description = 'Posted a comment on a Confluence page or blog post' WHERE "activityType" = 'comment' AND platform = 'confluence';
15+
UPDATE "activityTypes" SET description = 'Created comment in a Confluence page or blog post' WHERE "activityType" = 'comment-created' AND platform = 'confluence';
16+
UPDATE "activityTypes" SET description = 'Created a new Confluence page' WHERE "activityType" = 'page-created' AND platform = 'confluence';
17+
UPDATE "activityTypes" SET description = 'Edited or updated a Confluence page' WHERE "activityType" = 'page-updated' AND platform = 'confluence';
18+
19+
-- Dev.to platform
20+
UPDATE "activityTypes" SET description = 'Commented on a Dev.to article' WHERE "activityType" = 'comment' AND platform = 'devto';
21+
22+
-- Discord platform
23+
UPDATE "activityTypes" SET description = 'Joined Discord server/guild' WHERE "activityType" = 'joined_guild' AND platform = 'discord';
24+
UPDATE "activityTypes" SET description = 'Sent a message in a Discord channel' WHERE "activityType" = 'message' AND platform = 'discord';
25+
UPDATE "activityTypes" SET description = 'Sent a message in a Discord thread' WHERE "activityType" = 'thread_message' AND platform = 'discord';
26+
UPDATE "activityTypes" SET description = 'Started thread in a Discord channel' WHERE "activityType" = 'thread_started' AND platform = 'discord';
27+
28+
-- Discourse platform
29+
UPDATE "activityTypes" SET description = 'Liked post in a Discourse forum' WHERE "activityType" = 'like' AND platform = 'discourse';
30+
UPDATE "activityTypes" SET description = 'Joined Discourse forum' WHERE "activityType" = 'join' AND platform = 'discourse';
31+
UPDATE "activityTypes" SET description = 'Created topic in a Discourse forum' WHERE "activityType" = 'create_topic' AND platform = 'discourse';
32+
UPDATE "activityTypes" SET description = 'Replied to topic in a Discourse forum' WHERE "activityType" = 'message_in_topic' AND platform = 'discourse';
33+
34+
-- Gerrit platform
35+
UPDATE "activityTypes" SET description = 'Abandoned a code change in Gerrit' WHERE "activityType" = 'changeset-abandoned' AND platform = 'gerrit';
36+
UPDATE "activityTypes" SET description = 'Closed a code review in Gerrit' WHERE "activityType" = 'changeset-closed' AND platform = 'gerrit';
37+
UPDATE "activityTypes" SET description = 'Submitted a new changeset in Gerrit' WHERE "activityType" = 'changeset-created' AND platform = 'gerrit';
38+
UPDATE "activityTypes" SET description = 'Merged a code change into the main branch in Gerrit' WHERE "activityType" = 'changeset-merged' AND platform = 'gerrit';
39+
UPDATE "activityTypes" SET description = 'Commented on a code changeset in Gerrit' WHERE "activityType" = 'changeset_comment-created' AND platform = 'gerrit';
40+
UPDATE "activityTypes" SET description = 'Uploaded a new patchset for review in Gerrit' WHERE "activityType" = 'patchset-created' AND platform = 'gerrit';
41+
UPDATE "activityTypes" SET description = 'Approved a code patchset for review in Gerrit' WHERE "activityType" = 'patchset_approval-created' AND platform = 'gerrit';
42+
UPDATE "activityTypes" SET description = 'Commented on a code patchset in Gerrit' WHERE "activityType" = 'patchset_comment-created' AND platform = 'gerrit';
43+
44+
-- Git platform
45+
UPDATE "activityTypes" SET description = 'Approved a Git commit during code review in the default branch' WHERE "activityType" = 'approved-commit' AND platform = 'git';
46+
UPDATE "activityTypes" SET description = 'Authored a Git commit in the default branch' WHERE "activityType" = 'authored-commit' AND platform = 'git';
47+
UPDATE "activityTypes" SET description = 'Co-authored a Git commit with another user in the default branch' WHERE "activityType" = 'co-authored-commit' AND platform = 'git';
48+
UPDATE "activityTypes" SET description = 'Committed changes to a repository in the default branch' WHERE "activityType" = 'committed-commit' AND platform = 'git';
49+
UPDATE "activityTypes" SET description = 'Indirectly influenced a Git commit''s creation in the default branch' WHERE "activityType" = 'influenced-commit' AND platform = 'git';
50+
UPDATE "activityTypes" SET description = 'Contributed ideas or guidance that led to a Git commit in the default branch' WHERE "activityType" = 'informed-commit' AND platform = 'git';
51+
UPDATE "activityTypes" SET description = 'Reported an issue fixed by a Git commit in the default branch' WHERE "activityType" = 'reported-commit' AND platform = 'git';
52+
UPDATE "activityTypes" SET description = 'Resolved an issue with a Git commit in the default branch' WHERE "activityType" = 'resolved-commit' AND platform = 'git';
53+
UPDATE "activityTypes" SET description = 'Reviewed a Git commit in the default branch' WHERE "activityType" = 'reviewed-commit' AND platform = 'git';
54+
UPDATE "activityTypes" SET description = 'Signed off on a Git commit for compliance/review in the default branch' WHERE "activityType" = 'signed-off-commit' AND platform = 'git';
55+
UPDATE "activityTypes" SET description = 'Tested changes and marked them accordingly in the default branch' WHERE "activityType" = 'tested-commit' AND platform = 'git';
56+
57+
-- GitHub platform
58+
UPDATE "activityTypes" SET description = 'Authored and pushed a commit in a pull request on GitHub' WHERE "activityType" = 'authored-commit' AND platform = 'github';
59+
UPDATE "activityTypes" SET description = 'Commented on a GitHub discussion' WHERE "activityType" = 'discussion-comment' AND platform = 'github';
60+
UPDATE "activityTypes" SET description = 'Started a GitHub discussion' WHERE "activityType" = 'discussion-started' AND platform = 'github';
61+
UPDATE "activityTypes" SET description = 'Forked a GitHub repository' WHERE "activityType" = 'fork' AND platform = 'github';
62+
UPDATE "activityTypes" SET description = 'Commented on a GitHub issue' WHERE "activityType" = 'issue-comment' AND platform = 'github';
63+
UPDATE "activityTypes" SET description = 'Closed a GitHub issue' WHERE "activityType" = 'issues-closed' AND platform = 'github';
64+
UPDATE "activityTypes" SET description = 'Opened a GitHub issue' WHERE "activityType" = 'issues-opened' AND platform = 'github';
65+
UPDATE "activityTypes" SET description = 'Assigned to a GitHub pull request' WHERE "activityType" = 'pull_request-assigned' AND platform = 'github';
66+
UPDATE "activityTypes" SET description = 'Closed a GitHub pull request' WHERE "activityType" = 'pull_request-closed' AND platform = 'github';
67+
UPDATE "activityTypes" SET description = 'Commented on a GitHub pull request' WHERE "activityType" = 'pull_request-comment' AND platform = 'github';
68+
UPDATE "activityTypes" SET description = 'Merged a GitHub pull request' WHERE "activityType" = 'pull_request-merged' AND platform = 'github';
69+
UPDATE "activityTypes" SET description = 'Opened a GitHub pull request' WHERE "activityType" = 'pull_request-opened' AND platform = 'github';
70+
UPDATE "activityTypes" SET description = 'Requested a review on a GitHub pull request' WHERE "activityType" = 'pull_request-review-requested' AND platform = 'github';
71+
UPDATE "activityTypes" SET description = 'Reviewed a GitHub pull request' WHERE "activityType" = 'pull_request-reviewed' AND platform = 'github';
72+
UPDATE "activityTypes" SET description = 'Starred a GitHub repository' WHERE "activityType" = 'star' AND platform = 'github';
73+
UPDATE "activityTypes" SET description = 'Unstarred a GitHub repository' WHERE "activityType" = 'unstar' AND platform = 'github';
74+
75+
-- GitLab platform
76+
UPDATE "activityTypes" SET description = 'Authored and pushed a commit in a merge request on GitLab' WHERE "activityType" = 'authored-commit' AND platform = 'gitlab';
77+
UPDATE "activityTypes" SET description = 'Forked a GitLab repository' WHERE "activityType" = 'fork' AND platform = 'gitlab';
78+
UPDATE "activityTypes" SET description = 'Commented on a GitLab issue' WHERE "activityType" = 'issue-comment' AND platform = 'gitlab';
79+
UPDATE "activityTypes" SET description = 'Closed a GitLab issue' WHERE "activityType" = 'issues-closed' AND platform = 'gitlab';
80+
UPDATE "activityTypes" SET description = 'Opened a GitLab issue' WHERE "activityType" = 'issues-opened' AND platform = 'gitlab';
81+
UPDATE "activityTypes" SET description = 'Assigned to a GitLab merge request' WHERE "activityType" = 'merge_request-assigned' AND platform = 'gitlab';
82+
UPDATE "activityTypes" SET description = 'Closed a GitLab merge request' WHERE "activityType" = 'merge_request-closed' AND platform = 'gitlab';
83+
UPDATE "activityTypes" SET description = 'Commented on a GitLab merge request' WHERE "activityType" = 'merge_request-comment' AND platform = 'gitlab';
84+
UPDATE "activityTypes" SET description = 'Merged a GitLab merge request' WHERE "activityType" = 'merge_request-merged' AND platform = 'gitlab';
85+
UPDATE "activityTypes" SET description = 'Opened a GitLab merge request' WHERE "activityType" = 'merge_request-opened' AND platform = 'gitlab';
86+
UPDATE "activityTypes" SET description = 'Approved a GitLab merge request review' WHERE "activityType" = 'merge_request-review-approved' AND platform = 'gitlab';
87+
UPDATE "activityTypes" SET description = 'Requested changes on a GitLab merge request' WHERE "activityType" = 'merge_request-review-changes-requested' AND platform = 'gitlab';
88+
UPDATE "activityTypes" SET description = 'Requested review on a GitLab merge request' WHERE "activityType" = 'merge_request-review-requested' AND platform = 'gitlab';
89+
UPDATE "activityTypes" SET description = 'Starred a GitLab repository' WHERE "activityType" = 'star' AND platform = 'gitlab';
90+
91+
-- Groups.io platform
92+
UPDATE "activityTypes" SET description = 'Sent message in a Groups.io mailing list' WHERE "activityType" = 'message' AND platform = 'groupsio';
93+
UPDATE "activityTypes" SET description = 'Joined Groups.io mailing list' WHERE "activityType" = 'member_join' AND platform = 'groupsio';
94+
UPDATE "activityTypes" SET description = 'Left Groups.io mailing list' WHERE "activityType" = 'member_leave' AND platform = 'groupsio';
95+
96+
-- Hackernews platform
97+
UPDATE "activityTypes" SET description = 'Commented on a Hacker News story' WHERE "activityType" = 'comment' AND platform = 'hackernews';
98+
UPDATE "activityTypes" SET description = 'Posted a story on Hacker News' WHERE "activityType" = 'post' AND platform = 'hackernews';
99+
100+
-- Jira platform
101+
UPDATE "activityTypes" SET description = 'Added an assignee to a Jira issue' WHERE "activityType" = 'issue-assigned' AND platform = 'jira';
102+
UPDATE "activityTypes" SET description = 'Added attachment to a Jira issue' WHERE "activityType" = 'issue-attachment-added' AND platform = 'jira';
103+
UPDATE "activityTypes" SET description = 'Closed a Jira issue' WHERE "activityType" = 'issue-closed' AND platform = 'jira';
104+
UPDATE "activityTypes" SET description = 'Created comment on a Jira issue' WHERE "activityType" = 'issue-comment-created' AND platform = 'jira';
105+
UPDATE "activityTypes" SET description = 'Updated comment on a Jira issue' WHERE "activityType" = 'issue-comment-updated' AND platform = 'jira';
106+
UPDATE "activityTypes" SET description = 'Created a Jira issue' WHERE "activityType" = 'issue-created' AND platform = 'jira';
107+
UPDATE "activityTypes" SET description = 'Updated a Jira issue' WHERE "activityType" = 'issue-updated' AND platform = 'jira';
108+
109+
-- LinkedIn platform
110+
UPDATE "activityTypes" SET description = 'Commented on a LinkedIn post' WHERE "activityType" = 'comment' AND platform = 'linkedin';
111+
UPDATE "activityTypes" SET description = 'Reacted to a LinkedIn post' WHERE "activityType" = 'reaction' AND platform = 'linkedin';
112+
113+
-- Reddit platform
114+
UPDATE "activityTypes" SET description = 'Commented on a Reddit post' WHERE "activityType" = 'comment' AND platform = 'reddit';
115+
UPDATE "activityTypes" SET description = 'Posted on Reddit' WHERE "activityType" = 'post' AND platform = 'reddit';
116+
117+
-- Slack platform
118+
UPDATE "activityTypes" SET description = 'Joined a Slack channel' WHERE "activityType" = 'channel_joined' AND platform = 'slack';
119+
UPDATE "activityTypes" SET description = 'Sent a message in a Slack channel' WHERE "activityType" = 'message' AND platform = 'slack';
120+
121+
-- Stack Overflow platform
122+
UPDATE "activityTypes" SET description = 'Answered a question on Stack Overflow' WHERE "activityType" = 'answer' AND platform = 'stackoverflow';
123+
UPDATE "activityTypes" SET description = 'Asked a question on Stack Overflow' WHERE "activityType" = 'question' AND platform = 'stackoverflow';
124+
125+
-- Twitter platform
126+
UPDATE "activityTypes" SET description = 'Used hashtag in a Twitter post' WHERE "activityType" = 'hashtag' AND platform = 'twitter';
127+
UPDATE "activityTypes" SET description = 'Mentioned user in a Twitter post' WHERE "activityType" = 'mention' AND platform = 'twitter';
128+
UPDATE "activityTypes" SET description = 'Followed user on Twitter' WHERE "activityType" = 'follow' AND platform = 'twitter';
129+
130+
-- Add NOT NULL constraint to description column
131+
ALTER TABLE "activityTypes" ALTER COLUMN description SET NOT NULL;

backend/src/services/integrationService.ts

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -902,13 +902,15 @@ export default class IntegrationService {
902902
}
903903

904904
async mapGithubRepos(integrationId, mapping, fireOnboarding = true) {
905+
this.options.log.info(`Mapping GitHub repos for integration ${integrationId}!`)
905906
const transaction = await SequelizeRepository.createTransaction(this.options)
906907

907908
const txOptions = {
908909
...this.options,
909910
transaction,
910911
}
911912
try {
913+
this.options.log.info(`Updating GitHub repos mapping for integration ${integrationId}!`)
912914
await GithubReposRepository.updateMapping(integrationId, mapping, txOptions)
913915

914916
// add the repos to the git integration
@@ -927,9 +929,11 @@ export default class IntegrationService {
927929
const collectionService = new CollectionService(txOptions)
928930

929931
for (const [segmentId, repositories] of Object.entries(repos)) {
932+
this.options.log.info(`Finding insights project for segment ${segmentId}!`)
930933
const [insightsProject] = await collectionService.findInsightsProjectsBySegmentId(segmentId)
931934

932935
if (insightsProject) {
936+
this.options.log.info(`Upserting segment repositories for segment ${segmentId}!`)
933937
await upsertSegmentRepositories(qx, {
934938
insightsProjectId: insightsProject.id,
935939
repositories,
@@ -945,7 +949,7 @@ export default class IntegrationService {
945949
for (const [segmentId, urls] of Object.entries(repos)) {
946950
let isGitintegrationConfigured
947951
const segmentOptions: IRepositoryOptions = {
948-
...this.options,
952+
...txOptions,
949953
currentSegments: [
950954
{
951955
...this.options.currentSegments[0],
@@ -954,6 +958,7 @@ export default class IntegrationService {
954958
],
955959
}
956960
try {
961+
this.options.log.info(`Finding Git integration for segment ${segmentId}!`)
957962
await IntegrationRepository.findByPlatform(PlatformType.GIT, segmentOptions)
958963

959964
isGitintegrationConfigured = true
@@ -962,15 +967,18 @@ export default class IntegrationService {
962967
}
963968

964969
if (isGitintegrationConfigured) {
970+
this.options.log.info(`Finding Git integration for segment ${segmentId}!`)
965971
const gitInfo = await this.gitGetRemotes(segmentOptions)
966972
const gitRemotes = gitInfo[segmentId as string].remotes
973+
this.options.log.info(`Updating Git integration for segment ${segmentId}!`)
967974
await this.gitConnectOrUpdate(
968975
{
969976
remotes: Array.from(new Set([...gitRemotes, ...urls])),
970977
},
971978
segmentOptions,
972979
)
973980
} else {
981+
this.options.log.info(`Updating Git integration for segment ${segmentId}!`)
974982
await this.gitConnectOrUpdate(
975983
{
976984
remotes: urls,
@@ -981,6 +989,7 @@ export default class IntegrationService {
981989
}
982990

983991
if (fireOnboarding) {
992+
this.options.log.info('Updating integration status to in-progress!')
984993
const integration = await IntegrationRepository.update(
985994
integrationId,
986995
{ status: 'in-progress' },
@@ -994,7 +1003,12 @@ export default class IntegrationService {
9941003

9951004
await SequelizeRepository.commitTransaction(transaction)
9961005
} catch (err) {
997-
await SequelizeRepository.rollbackTransaction(transaction)
1006+
this.options.log.error(err, 'Error while mapping GitHub repos!')
1007+
try {
1008+
await SequelizeRepository.rollbackTransaction(transaction)
1009+
} catch (rErr) {
1010+
this.options.log.error(rErr, 'Error while rolling back transaction!')
1011+
}
9981012
throw err
9991013
}
10001014
}
@@ -1266,7 +1280,9 @@ export default class IntegrationService {
12661280
return null
12671281
}
12681282

1269-
const transaction = await SequelizeRepository.createTransaction(options || this.options)
1283+
const existingTransaction = SequelizeRepository.getTransaction(options || this.options)
1284+
const transaction =
1285+
existingTransaction || (await SequelizeRepository.createTransaction(options || this.options))
12701286
let integration
12711287

12721288
try {
@@ -1291,9 +1307,15 @@ export default class IntegrationService {
12911307
// inheritFromExistingRepos defaults to true during migration until all repos are migrated then git.repositories can be used as source of truth instead of existing repo tables
12921308
)
12931309

1294-
await SequelizeRepository.commitTransaction(transaction)
1310+
// Only commit if we created the transaction ourselves
1311+
if (!existingTransaction) {
1312+
await SequelizeRepository.commitTransaction(transaction)
1313+
}
12951314
} catch (err) {
1296-
await SequelizeRepository.rollbackTransaction(transaction)
1315+
// Only rollback if we created the transaction ourselves
1316+
if (!existingTransaction) {
1317+
await SequelizeRepository.rollbackTransaction(transaction)
1318+
}
12971319
this.options.log.error(`gitConnectOrUpdate failed with error: ${err}`)
12981320
throw err
12991321
}

services/apps/cache_worker/src/activities.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
syncOrganization,
66
} from './activities/computeAggs/organization'
77
import {
8-
findNewActivityPlatforms,
98
getActiveMembersTimeseries,
109
getActiveOrganizationsTimeseries,
1110
getActivePlatforms,
@@ -42,7 +41,6 @@ export {
4241
getActivitiesByType,
4342
saveToCache,
4443
getActivePlatforms,
45-
findNewActivityPlatforms,
4644
updateMemberMergeSuggestionsLastGeneratedAt,
4745
getOrganizationIdsFromRedis,
4846
dropOrgIdFromRedis,

0 commit comments

Comments
 (0)