Skip to content

Commit ce33b23

Browse files
committed
Merge branch 'main' into deprecate-questdb-CM-420
2 parents 4d54db3 + 260b6e5 commit ce33b23

17 files changed

Lines changed: 199 additions & 59 deletions

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
}

frontend/src/modules/activity/components/activity-timeline.vue

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -311,19 +311,24 @@ const fetchActivities = async ({ reset } = { reset: false }) => {
311311
if (loading.value) {
312312
return;
313313
}
314-
const filterToApply = {
315-
platform: platform.value ? { in: [platform.value] } : undefined,
316-
};
317314
318-
if (props.entityType === 'member') {
319-
filterToApply.memberId = { in: [props.entity.id] };
320-
} else {
321-
filterToApply.organizationId = { in: [props.entity.id] };
322-
}
315+
// Default filter to apply
316+
const filterToApply: {
317+
and: any[];
318+
} = {
319+
and: [
320+
{
321+
timestamp: {
322+
gte: timestamp.value,
323+
},
324+
},
325+
],
326+
};
323327
324-
if (props.entity.id) {
325-
if (query.value && query.value !== '') {
326-
filterToApply.or = [
328+
// Add search query filter to and clause
329+
if (props.entity.id && !!query.value) {
330+
filterToApply.and.push({
331+
or: [
327332
{
328333
channel: {
329334
textContains: query.value,
@@ -334,17 +339,27 @@ const fetchActivities = async ({ reset } = { reset: false }) => {
334339
textContains: query.value,
335340
},
336341
},
337-
];
338-
}
342+
],
343+
});
339344
}
340345
341-
filterToApply.and = [
342-
{
343-
timestamp: {
344-
gte: timestamp.value,
345-
},
346-
},
347-
];
346+
// Add platform filter to and clause
347+
if (platform.value) {
348+
filterToApply.and.push({
349+
platform: { in: [platform.value] },
350+
});
351+
}
352+
353+
// Add entity filter to and clause
354+
if (props.entityType === 'member') {
355+
filterToApply.and.push({
356+
memberId: { in: [props.entity.id] },
357+
});
358+
} else {
359+
filterToApply.and.push({
360+
organizationId: { in: [props.entity.id] },
361+
});
362+
}
348363
349364
if (reset) {
350365
activities.value.length = 0;

frontend/src/modules/admin/modules/insights-projects/components/lf-insights-project-add.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,6 @@ const onSubmit = () => {
286286
const request = buildRequest({
287287
...form,
288288
});
289-
console.log(request);
290289
if (isEditForm.value) {
291290
updateMutation.mutate({
292291
id: props.insightsProjectId as string,

frontend/src/modules/admin/modules/insights-projects/pages/insights-projects.page.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,6 @@ const projects = computed((): InsightsProjectModel[] => {
197197
});
198198
199199
watch(() => route.query, (query) => {
200-
console.log('query', query);
201200
if (query?.search !== search.value) {
202201
search.value = query.search as string || '';
203202
}
@@ -207,7 +206,6 @@ watch(() => route.query, (query) => {
207206
208207
watch(search, (value) => {
209208
if (value !== route.query?.search) {
210-
console.log('search', value);
211209
router.replace({
212210
query: {
213211
...route.query,

frontend/src/modules/admin/modules/insights-projects/services/insights-projects.service.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ export class InsightsProjectsService {
3737
}
3838

3939
update(id: string, project: InsightsProjectRequest) {
40-
console.log(project);
4140
return authAxios
4241
.post<InsightsProjectModel>(
4342
`/collections/insights-projects/${id}`,

frontend/src/shared/form/autocomplete-one-input.vue

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,15 +188,12 @@ export default {
188188
189189
methods: {
190190
async onChange(value) {
191-
const { query } = this.$refs.input;
192-
193191
if (
194-
typeof query === 'string'
195-
&& query !== ''
192+
this.currentQuery !== ''
196193
&& this.createIfNotFound
197194
&& !value
198195
) {
199-
const newItem = await this.createFn(query);
196+
const newItem = await this.createFn(this.currentQuery);
200197
this.localOptions.push(newItem);
201198
this.$emit('update:modelValue', newItem);
202199
} else {

services/libs/common_services/src/services/llm.service.ts

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,22 @@ export class LlmService extends LoggerBase {
3636
) {
3737
super(parentLog)
3838

39+
if (!bedrockCredentials.accessKeyId || !bedrockCredentials.secretAccessKey) {
40+
this.log.warn('LLM usage is not configured properly. Missing Bedrock credentials!')
41+
}
42+
3943
this.qx = qx
4044
this.clientRegionMap = new Map()
4145
}
4246

4347
private client(settings: ILlmSettings): BedrockRuntimeClient {
4448
const region = LLM_MODEL_REGION_MAP[settings.modelId]
4549

50+
if (!this.bedrockCredentials.accessKeyId || !this.bedrockCredentials.secretAccessKey) {
51+
this.log.warn('LLM usage is not configured properly. Missing Bedrock credentials!')
52+
return null
53+
}
54+
4655
let client: BedrockRuntimeClient
4756
if (this.clientRegionMap.has(region)) {
4857
client = this.clientRegionMap.get(region)
@@ -67,7 +76,11 @@ export class LlmService extends LoggerBase {
6776
metadata?: Record<string, unknown>,
6877
saveHistory = true,
6978
): Promise<ILlmResponse> {
70-
if (!IS_LLM_ENABLED) {
79+
if (
80+
!IS_LLM_ENABLED ||
81+
!this.bedrockCredentials.accessKeyId ||
82+
!this.bedrockCredentials.secretAccessKey
83+
) {
7184
this.log.error('LLM usage is disabled. Check CROWD_LLM_ENABLED env variable!')
7285
return
7386
}
@@ -158,6 +171,12 @@ export class LlmService extends LoggerBase {
158171
): Promise<ILlmResult<LlmMemberEnrichmentResult>> {
159172
const response = await this.queryLlm(LlmQueryType.MEMBER_ENRICHMENT, prompt, memberId)
160173

174+
if (!response) {
175+
return {
176+
result: null,
177+
} as ILlmResult<LlmMemberEnrichmentResult>
178+
}
179+
161180
const result = JSON.parse(response.answer)
162181

163182
return {
@@ -175,6 +194,12 @@ export class LlmService extends LoggerBase {
175194
memberId,
176195
)
177196

197+
if (!response) {
198+
return {
199+
result: null,
200+
} as ILlmResult<{ profileIndex: number }>
201+
}
202+
178203
const result = JSON.parse(response.answer)
179204

180205
return {
@@ -193,6 +218,12 @@ export class LlmService extends LoggerBase {
193218
memberId,
194219
)
195220

221+
if (!response) {
222+
return {
223+
result: null,
224+
} as ILlmResult<T>
225+
}
226+
196227
const result = JSON.parse(response.answer)
197228

198229
return {
@@ -211,6 +242,12 @@ export class LlmService extends LoggerBase {
211242
memberId,
212243
)
213244

245+
if (!response) {
246+
return {
247+
result: null,
248+
} as ILlmResult<T>
249+
}
250+
214251
const result = JSON.parse(response.answer)
215252

216253
return {
@@ -225,6 +262,12 @@ export class LlmService extends LoggerBase {
225262
prompt,
226263
)
227264

265+
if (!response) {
266+
return {
267+
result: null,
268+
} as ILlmResult<T>
269+
}
270+
228271
const result = JSON.parse(response.answer)
229272

230273
return {
@@ -236,6 +279,12 @@ export class LlmService extends LoggerBase {
236279
public async findRepoCategories<T>(prompt: string): Promise<ILlmResult<T>> {
237280
const response = await this.queryLlm(LlmQueryType.REPO_CATEGORIES, prompt)
238281

282+
if (!response) {
283+
return {
284+
result: null,
285+
} as ILlmResult<T>
286+
}
287+
239288
const result = JSON.parse(response.answer)
240289

241290
return {
@@ -247,6 +296,12 @@ export class LlmService extends LoggerBase {
247296
public async findRepoCollections<T>(prompt: string): Promise<ILlmResult<T>> {
248297
const response = await this.queryLlm(LlmQueryType.REPO_COLLECTIONS, prompt)
249298

299+
if (!response) {
300+
return {
301+
result: null,
302+
} as ILlmResult<T>
303+
}
304+
250305
const result = JSON.parse(response.answer)
251306

252307
return {

services/libs/data-access-layer/src/members/organizations.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,23 @@ export async function deleteMemberOrganizations(
245245
params.ids = ids
246246
}
247247

248-
const query = `${baseQuery} WHERE ${conditions.join(' AND ')};`
248+
const whereClause = conditions.join(' AND ')
249+
const query = `${baseQuery} WHERE ${whereClause};`
249250

250-
await qx.result(query, params)
251+
await qx.tx(async (tx) => {
252+
// First delete from memberOrganizationAffiliationOverrides using the same conditions
253+
await tx.result(
254+
`DELETE FROM "memberOrganizationAffiliationOverrides"
255+
WHERE "memberOrganizationId" IN (
256+
SELECT "id" FROM "memberOrganizations"
257+
WHERE ${whereClause}
258+
)`,
259+
params,
260+
)
261+
262+
// Then perform the soft/hard delete on memberOrganizations
263+
await tx.result(query, params)
264+
})
251265
}
252266

253267
export async function cleanSoftDeletedMemberOrganization(

0 commit comments

Comments
 (0)