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;
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,
export const DUNGEON_TRAVEL_BLOCK = 3000;
export const EVENT_FLUSH_INTERVAL = 10000;
-export const EVENT_SECOND_BUCKET = 3;
+export const EVENT_SECOND_BUCKET = 2;