Skip to content

Commit 7000192

Browse files
committed
Merge branch 'main' into deprecate-questdb-CM-420
2 parents f873759 + 4f96a8f commit 7000192

11 files changed

Lines changed: 369 additions & 113 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;

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,
@@ -38,7 +37,6 @@ export {
3837
getActivitiesTimeseries,
3938
saveToCache,
4039
getActivePlatforms,
41-
findNewActivityPlatforms,
4240
updateMemberMergeSuggestionsLastGeneratedAt,
4341
getOrganizationIdsFromRedis,
4442
dropOrgIdFromRedis,

services/apps/cache_worker/src/activities/dashboard-cache/refreshDashboardCache.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,24 +37,6 @@ export async function getActivePlatforms(leafSegmentIds: string[]): Promise<stri
3737
return integrationRepo.findActivePlatforms(leafSegmentIds)
3838
}
3939

40-
export async function findNewActivityPlatforms(
41-
dashboardLastRefreshedAt: string,
42-
leafSegmentIds: string[],
43-
): Promise<string[]> {
44-
// TODO questdb to tinybird
45-
// const result = await getNewActivityPlatforms(svc.qdb, {
46-
// segmentIds: leafSegmentIds,
47-
// after: new Date(Date.parse(dashboardLastRefreshedAt)),
48-
// })
49-
50-
// return result.platforms
51-
52-
// TODO questdb to tinybird remove this log once fixed - just to keep the linter happy
53-
svc.log.info({ dashboardLastRefreshedAt, leafSegmentIds }, 'findNewActivityPlatforms')
54-
55-
return []
56-
}
57-
5840
export async function updateMemberMergeSuggestionsLastGeneratedAt(
5941
segmentId: string,
6042
): Promise<void> {

services/apps/cache_worker/src/workflows/refreshDashboardCache.ts

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -52,24 +52,7 @@ export async function refreshDashboardCache(
5252
for (const platform of activePlatforms) {
5353
await refreshDashboardCacheForAllTimeranges(args.segmentId, args.leafSegmentIds, platform)
5454
}
55-
} else {
56-
// first check if there's a new activity between dashboardLastRefreshedAt and now()
57-
const platforms = await activity.findNewActivityPlatforms(
58-
dashboardLastRefreshedAt,
59-
args.leafSegmentIds,
60-
)
61-
62-
// only refresh the main view and returned platform views if there are new activities
63-
if (platforms && platforms.length > 0) {
64-
// refresh the main view
65-
await refreshDashboardCacheForAllTimeranges(args.segmentId, args.leafSegmentIds)
66-
67-
for (const platform of platforms) {
68-
await refreshDashboardCacheForAllTimeranges(args.segmentId, args.leafSegmentIds, platform)
69-
}
70-
}
7155
}
72-
7356
// update dashboardLastRefreshedAt
7457
await activity.updateMemberMergeSuggestionsLastGeneratedAt(args.segmentId)
7558
}

services/apps/git_integration/src/crowdgit/services/maintainer/bedrock.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from typing import Generic, TypeVar
33

44
import aioboto3
5+
from botocore.config import Config
56
from pydantic import BaseModel, ValidationError
67

78
from crowdgit.logger import logger
@@ -20,21 +21,22 @@ class BedrockResponse(BaseModel, Generic[T]):
2021

2122

2223
async def invoke_bedrock(
23-
instructions, pydantic_model: type[T], replacements=None, max_tokens=120000, temperature=0
24+
instruction, pydantic_model: type[T], replacements=None, max_tokens=65000, temperature=0
2425
) -> BedrockResponse[T]:
2526
session = aioboto3.Session(
2627
aws_access_key_id=CROWD_AWS_BEDROCK_ACCESS_KEY_ID,
2728
aws_secret_access_key=CROWD_AWS_BEDROCK_SECRET_ACCESS_KEY,
2829
)
2930

3031
async with session.client(
31-
service_name="bedrock-runtime", region_name=CROWD_AWS_BEDROCK_REGION
32+
service_name="bedrock-runtime",
33+
region_name=CROWD_AWS_BEDROCK_REGION,
34+
config=Config(
35+
read_timeout=300, # 5 minutes timeout for reading response
36+
connect_timeout=60, # 1 minute timeout for connection
37+
retries={"max_attempts": 3}, # Retry failed requests
38+
),
3239
) as bedrock_client:
33-
# Join the instructions into a single string
34-
instruction = (
35-
"Human:" + "\n".join(instructions) + '\n"""\nAnswer in JSON formatAssistant:{\n"""'
36-
)
37-
3840
# Apply replacements to the instruction string
3941
if replacements:
4042
for key, value in replacements.items():
@@ -52,6 +54,7 @@ async def invoke_bedrock(
5254
body = json.dumps(
5355
{
5456
"anthropic_version": "bedrock-2023-05-31",
57+
"system": "You are a precise JSON extraction assistant. You MUST respond with valid JSON only. Never use markdown formatting, code blocks, or any additional text. Your response must be parseable by json.loads() directly.",
5558
"messages": [
5659
{
5760
"role": "user",
@@ -69,16 +72,20 @@ async def invoke_bedrock(
6972
)
7073

7174
try:
72-
modelId = "anthropic.claude-3-5-sonnet-20240620-v1:0"
75+
modelId = "us.anthropic.claude-sonnet-4-20250514-v1:0"
7376
accept = "application/json"
7477
contentType = "application/json"
7578
response = await bedrock_client.invoke_model(
7679
body=body, modelId=modelId, accept=accept, contentType=contentType
7780
)
81+
7882
try:
7983
body_bytes = await response["body"].read()
8084
response_body = json.loads(body_bytes.decode("utf-8"))
81-
output = json.loads(response_body["content"][0]["text"].replace('"""', ""))
85+
raw_text = response_body["content"][0]["text"].replace('"""', "").strip()
86+
87+
# Expect pure JSON - no markdown handling
88+
output = json.loads(raw_text)
8289

8390
# Calculate cost
8491
input_tokens = response_body["usage"]["input_tokens"]

0 commit comments

Comments
 (0)