@@ -244,27 +244,62 @@ export default class ActivityService extends LoggerBase {
244
244
platform : toUpdate . platform || ( original . platform as PlatformType ) ,
245
245
} )
246
246
247
- await updateActivity ( this . qdbStore . connection ( ) , id , {
248
- tenantId : tenantId ,
249
- segmentId : segmentId ,
250
- type : toUpdate . type || original . type ,
251
- isContribution : toUpdate . isContribution || original . isContribution ,
252
- score : toUpdate . score || original . score ,
253
- sourceId : toUpdate . sourceId || original . sourceId ,
254
- sourceParentId : toUpdate . sourceParentId || original . sourceParentId ,
255
- memberId : toUpdate . memberId || original . memberId ,
256
- username : toUpdate . username || original . username ,
257
- sentiment : toUpdate . sentiment || original . sentiment ,
258
- attributes : toUpdate . attributes || original . attributes ,
259
- body : escapeNullByte ( toUpdate . body || original . body ) ,
260
- title : escapeNullByte ( toUpdate . title || original . title ) ,
261
- channel : toUpdate . channel || original . channel ,
262
- url : toUpdate . url || original . url ,
263
- organizationId : toUpdate . organizationId || original . organizationId ,
264
- platform : toUpdate . platform || ( original . platform as PlatformType ) ,
265
- isBotActivity : memberInfo . isBot ,
266
- isTeamMemberActivity : memberInfo . isTeamMember ,
267
- } )
247
+ // use insert instead of update to avoid using pg protocol with questdb
248
+ try {
249
+ await insertActivities ( [
250
+ {
251
+ id,
252
+ memberId : toUpdate . memberId || original . memberId ,
253
+ timestamp : original . timestamp ,
254
+ platform : toUpdate . platform || ( original . platform as PlatformType ) ,
255
+ type : toUpdate . type || original . type ,
256
+ isContribution : toUpdate . isContribution || original . isContribution ,
257
+ score : toUpdate . score || original . score ,
258
+ sourceId : toUpdate . sourceId || original . sourceId ,
259
+ sourceParentId : toUpdate . sourceParentId || original . sourceParentId ,
260
+ tenantId : tenantId ,
261
+ attributes : toUpdate . attributes || original . attributes ,
262
+ sentiment : toUpdate . sentiment || original . sentiment ,
263
+ body : escapeNullByte ( toUpdate . body || original . body ) ,
264
+ title : escapeNullByte ( toUpdate . title || original . title ) ,
265
+ channel : toUpdate . channel || original . channel ,
266
+ url : toUpdate . url || original . url ,
267
+ username : toUpdate . username || original . username ,
268
+ objectMemberId : activity . objectMemberId ,
269
+ objectMemberUsername : activity . objectMemberUsername ,
270
+ segmentId : segmentId ,
271
+ organizationId : toUpdate . organizationId || original . organizationId ,
272
+ isBotActivity : memberInfo . isBot ,
273
+ isTeamMemberActivity : memberInfo . isTeamMember ,
274
+ importHash : original . importHash ,
275
+ } ,
276
+ ] )
277
+ } catch ( error ) {
278
+ this . log . error ( 'Error updating (by inserting) activity in QuestDB:' , error )
279
+ throw error
280
+ }
281
+
282
+ // await updateActivity(this.qdbStore.connection(), id, {
283
+ // tenantId: tenantId,
284
+ // segmentId: segmentId,
285
+ // type: toUpdate.type || original.type,
286
+ // isContribution: toUpdate.isContribution || original.isContribution,
287
+ // score: toUpdate.score || original.score,
288
+ // sourceId: toUpdate.sourceId || original.sourceId,
289
+ // sourceParentId: toUpdate.sourceParentId || original.sourceParentId,
290
+ // memberId: toUpdate.memberId || original.memberId,
291
+ // username: toUpdate.username || original.username,
292
+ // sentiment: toUpdate.sentiment || original.sentiment,
293
+ // attributes: toUpdate.attributes || original.attributes,
294
+ // body: escapeNullByte(toUpdate.body || original.body),
295
+ // title: escapeNullByte(toUpdate.title || original.title),
296
+ // channel: toUpdate.channel || original.channel,
297
+ // url: toUpdate.url || original.url,
298
+ // organizationId: toUpdate.organizationId || original.organizationId,
299
+ // platform: toUpdate.platform || (original.platform as PlatformType),
300
+ // isBotActivity: memberInfo.isBot,
301
+ // isTeamMemberActivity: memberInfo.isTeamMember,
302
+ // })
268
303
269
304
return true
270
305
} else {
0 commit comments