mirror of
https://github.com/Unleash/unleash.git
synced 2025-03-04 00:18:40 +01:00
## About the changes Schedules a best-effort task setting the value of events.created_by_user_id based on what is found in the created_by column and if it's capable of resolving that to a userid/a system id. The process is executed in the events-store, it takes a chunk of events that haven't been processed yet, attempts to join users and api_tokens tables on created_by = username/email, loops through and tries to figure out an id to set. Then updates the record. --------- Co-authored-by: Gastón Fournier <gaston@getunleash.io>
32 lines
1.1 KiB
TypeScript
32 lines
1.1 KiB
TypeScript
import FakeEventStore from '../../../test/fixtures/fake-event-store';
|
|
import FakeFeatureTagStore from '../../../test/fixtures/fake-feature-tag-store';
|
|
import { Db } from '../../db/db';
|
|
import EventStore from './event-store';
|
|
import FeatureTagStore from '../../db/feature-tag-store';
|
|
import { EventService } from '../../services';
|
|
import { IUnleashConfig } from '../../types';
|
|
|
|
export const createEventsService: (
|
|
db: Db,
|
|
config: IUnleashConfig,
|
|
) => EventService = (db, config) => {
|
|
const eventStore = new EventStore(
|
|
db,
|
|
config.getLogger,
|
|
config.flagResolver,
|
|
);
|
|
const featureTagStore = new FeatureTagStore(
|
|
db,
|
|
config.eventBus,
|
|
config.getLogger,
|
|
);
|
|
return new EventService({ eventStore, featureTagStore }, config);
|
|
};
|
|
|
|
export const createFakeEventsService: (config: IUnleashConfig) => EventService =
|
|
(config) => {
|
|
const eventStore = new FakeEventStore();
|
|
const featureTagStore = new FakeFeatureTagStore();
|
|
return new EventService({ eventStore, featureTagStore }, config);
|
|
};
|