feature(worker+api): improve buffer

This commit is contained in:
Carl-Gerhard Lindesvärd
2024-09-17 23:37:11 +02:00
parent 32e91959f6
commit 545cbfd520
18 changed files with 1484 additions and 432 deletions

View File

@@ -9,7 +9,6 @@ import type { IChartEventFilter } from '@openpanel/validation';
import { botBuffer, eventBuffer } from '../buffers';
import {
TABLE_NAMES,
ch,
chQuery,
convertClickhouseDateToJs,
formatClickhouseDate,
@@ -339,7 +338,7 @@ export async function createEvent(payload: IServiceCreateEventPayload) {
sdk_version: payload.sdkVersion ?? '',
};
await eventBuffer.insert(event);
await eventBuffer.add(event);
return {
document: event,
@@ -562,7 +561,7 @@ export function createBotEvent({
createdAt,
path,
}: IServiceCreateBotEventPayload) {
return botBuffer.insert({
return botBuffer.add({
id: uuid(),
name,
type,
@@ -593,7 +592,7 @@ export async function getLastScreenViewFromProfileId({
}
const eventInBuffer = await eventBuffer.find(
(item) => item.event.profile_id === profileId,
(item) => item.profile_id === profileId,
);
if (eventInBuffer) {

View File

@@ -222,7 +222,7 @@ export async function upsertProfile({
projectId,
isExternal,
}: IServiceUpsertProfile) {
return profileBuffer.insert({
return profileBuffer.add({
id,
first_name: firstName!,
last_name: lastName!,