From 237ff9784f04407af62e653ea2235d052944503d Mon Sep 17 00:00:00 2001 From: xangelo Date: Mon, 16 Oct 2023 13:32:01 -0400 Subject: [PATCH] fix: remove event date bucketing --- src/server/events.ts | 19 +------------------ src/shared/constants.ts | 2 +- 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/src/server/events.ts b/src/server/events.ts index b77f556..7b52951 100644 --- a/src/server/events.ts +++ b/src/server/events.ts @@ -3,7 +3,7 @@ import { version } from '../../package.json'; import { CreatedEvent, Event, EventName } from '../shared/event'; import { isEqual } from 'lodash'; import { logger } from './lib/logger'; -import { EVENT_FLUSH_INTERVAL, EVENT_SECOND_BUCKET } from '../shared/constants'; +import { EVENT_FLUSH_INTERVAL } from '../shared/constants'; const eventBuffer: CreatedEvent[] = []; const maxToAdd = 10; @@ -17,23 +17,6 @@ export async function flushBuffer() { setTimeout(flushBuffer, EVENT_FLUSH_INTERVAL); } -function bucketTime(date: Date): Date { - const d = new Date(); - d.setFullYear(date.getFullYear()); - d.setMonth(date.getMonth()); - d.setDate(date.getDate()); - d.setHours(date.getHours()); - d.setMinutes(date.getMinutes()); - d.setMilliseconds(0); - - const s = date.getSeconds(); - - // round down to closest 5 second interval - d.setSeconds(s - (s%EVENT_SECOND_BUCKET)); - return d; -} - - export async function addEvent(event_name: EventName, player_id: string, props?: any, created?: Date) { eventBuffer.push({ event_name, diff --git a/src/shared/constants.ts b/src/shared/constants.ts index 7804b56..2ca98e8 100644 --- a/src/shared/constants.ts +++ b/src/shared/constants.ts @@ -7,4 +7,4 @@ export const CHANCE_TO_FIGHT_SPECIAL = 10; export const DUNGEON_TRAVEL_BLOCK = 3000; export const EVENT_FLUSH_INTERVAL = 10000; -export const EVENT_SECOND_BUCKET = 3; +export const EVENT_SECOND_BUCKET = 2; -- 2.25.1