mirror of
https://github.com/Unleash/unleash.git
synced 2025-04-10 01:16:39 +02:00
fix: project feature_count should not include archived (#2919)
fixes: #2923
This commit is contained in:
parent
5ceab6f989
commit
bb20c6d102
@ -88,6 +88,7 @@ class ProjectStore implements IProjectStore {
|
|||||||
const projectTimer = this.timer('getProjectsWithCount');
|
const projectTimer = this.timer('getProjectsWithCount');
|
||||||
let projects = this.db(TABLE)
|
let projects = this.db(TABLE)
|
||||||
.leftJoin('features', 'features.project', 'projects.id')
|
.leftJoin('features', 'features.project', 'projects.id')
|
||||||
|
.where('features.archived_at', null)
|
||||||
.orderBy('projects.name', 'asc');
|
.orderBy('projects.name', 'asc');
|
||||||
if (query) {
|
if (query) {
|
||||||
projects = projects.where(query);
|
projects = projects.where(query);
|
||||||
|
@ -1026,3 +1026,30 @@ test('Should allow bulk update of only groups', async () => {
|
|||||||
'some-admin-user',
|
'some-admin-user',
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should only count active feature toggles for project', async () => {
|
||||||
|
const project = {
|
||||||
|
id: 'only-active',
|
||||||
|
name: 'New project',
|
||||||
|
description: 'Blah',
|
||||||
|
};
|
||||||
|
|
||||||
|
await projectService.createProject(project, user);
|
||||||
|
|
||||||
|
await stores.featureToggleStore.create(project.id, {
|
||||||
|
name: 'only-active-t1',
|
||||||
|
project: project.id,
|
||||||
|
enabled: false,
|
||||||
|
});
|
||||||
|
await stores.featureToggleStore.create(project.id, {
|
||||||
|
name: 'only-active-t2',
|
||||||
|
project: project.id,
|
||||||
|
enabled: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
await featureToggleService.archiveToggle('only-active-t2', 'me');
|
||||||
|
|
||||||
|
const projects = await projectService.getProjects();
|
||||||
|
const theProject = projects.find((p) => p.id === project.id);
|
||||||
|
expect(theProject?.featureCount).toBe(1);
|
||||||
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user