mirror of
https://github.com/Unleash/unleash.git
synced 2025-09-19 17:52:45 +02:00
bug fixes: only use environment in events with environment
This commit is contained in:
parent
05ef4a05b4
commit
553c5c4927
@ -191,14 +191,19 @@ export class EventStore implements IEventStore {
|
||||
}
|
||||
}
|
||||
|
||||
private typeIsInteresting = (builder: Knex.QueryBuilder) =>
|
||||
private typeIsInteresting =
|
||||
(environment?: string) => (builder: Knex.QueryBuilder) =>
|
||||
builder
|
||||
.andWhere((inner) =>
|
||||
.andWhere((inner) => {
|
||||
inner
|
||||
.whereNotNull('feature_name')
|
||||
.whereNotIn('type', [FEATURE_CREATED, FEATURE_TAGGED])
|
||||
.whereNot('type', 'LIKE', 'change-%'),
|
||||
)
|
||||
.whereNot('type', 'LIKE', 'change-%');
|
||||
if (environment) {
|
||||
inner.where('environment', environment);
|
||||
}
|
||||
return inner;
|
||||
})
|
||||
.orWhereIn('type', [
|
||||
SEGMENT_UPDATED,
|
||||
FEATURE_IMPORT,
|
||||
@ -214,13 +219,9 @@ export class EventStore implements IEventStore {
|
||||
const stopTimer = this.metricTimer('getMaxRevisionId');
|
||||
const query = this.db(TABLE)
|
||||
.max('id')
|
||||
.where(this.typeIsInteresting)
|
||||
.where(this.typeIsInteresting(environment))
|
||||
.andWhere('id', '>=', largerThan);
|
||||
|
||||
if (environment) {
|
||||
query.where('environment', environment);
|
||||
}
|
||||
|
||||
const row = await query.first();
|
||||
stopTimer();
|
||||
return row?.max ?? 0;
|
||||
@ -233,7 +234,7 @@ export class EventStore implements IEventStore {
|
||||
.from(TABLE)
|
||||
.where('id', '>', start)
|
||||
.andWhere('id', '<=', end)
|
||||
.andWhere(this.typeIsInteresting)
|
||||
.andWhere(this.typeIsInteresting())
|
||||
.orderBy('id', 'asc');
|
||||
|
||||
const rows = await query;
|
||||
|
@ -18,7 +18,7 @@ export default class ConfigurationRevisionService extends EventEmitter {
|
||||
|
||||
private revisionId: number;
|
||||
|
||||
private maxRevisionId: Record<string, number> = {};
|
||||
private maxRevisionId: Map<string, number> = new Map();
|
||||
|
||||
private flagResolver: IFlagResolver;
|
||||
|
||||
@ -73,10 +73,10 @@ export default class ConfigurationRevisionService extends EventEmitter {
|
||||
|
||||
async updateMaxEnvironmentRevisionId(environment: string): Promise<number> {
|
||||
const envRevisionId = await this.eventStore.getMaxRevisionId(
|
||||
this.revisionId,
|
||||
this.maxRevisionId[environment],
|
||||
environment,
|
||||
);
|
||||
if (this.maxRevisionId[environment] < envRevisionId) {
|
||||
if (this.maxRevisionId[environment] ?? 0 < envRevisionId) {
|
||||
this.maxRevisionId[environment] = envRevisionId;
|
||||
}
|
||||
|
||||
@ -93,8 +93,12 @@ export default class ConfigurationRevisionService extends EventEmitter {
|
||||
);
|
||||
if (this.revisionId !== revisionId) {
|
||||
this.logger.debug(
|
||||
'Updating feature configuration with new revision Id',
|
||||
revisionId,
|
||||
`Updating feature configuration with new revision Id ${revisionId} and all envs: ${Object.keys(this.maxRevisionId).join(', ')}`,
|
||||
);
|
||||
await Promise.allSettled(
|
||||
Object.keys(this.maxRevisionId).map((environment) =>
|
||||
this.updateMaxEnvironmentRevisionId(environment),
|
||||
),
|
||||
);
|
||||
this.revisionId = revisionId;
|
||||
if (emit) {
|
||||
|
Loading…
Reference in New Issue
Block a user