1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00

fix: project feature_count should not include archived (#2919)

fixes: #2923
This commit is contained in:
Ivar Conradi Østhus 2023-01-18 15:58:27 +01:00 committed by GitHub
parent 5ceab6f989
commit bb20c6d102
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 0 deletions

View File

@ -88,6 +88,7 @@ class ProjectStore implements IProjectStore {
const projectTimer = this.timer('getProjectsWithCount');
let projects = this.db(TABLE)
.leftJoin('features', 'features.project', 'projects.id')
.where('features.archived_at', null)
.orderBy('projects.name', 'asc');
if (query) {
projects = projects.where(query);

View File

@ -1026,3 +1026,30 @@ test('Should allow bulk update of only groups', async () => {
'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);
});