Skip to content

Commit

Permalink
1-3120: remove project connected environments (#8775)
Browse files Browse the repository at this point in the history
Remove everything related to the connected environment count for project
status. We decided that because we don't have anywhere to link it to at
the moment, we don't want to show it yet.
  • Loading branch information
thomasheartman authored Nov 18, 2024
1 parent fb9c754 commit a55a956
Show file tree
Hide file tree
Showing 10 changed files with 1 addition and 102 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import UsersIcon from '@mui/icons-material/Group';
import { Link } from 'react-router-dom';
import ApiKeyIcon from '@mui/icons-material/Key';
import SegmentsIcon from '@mui/icons-material/DonutLarge';
import ConnectedIcon from '@mui/icons-material/Cable';
import { useProjectStatus } from 'hooks/api/getters/useProjectStatus/useProjectStatus';
import useLoading from 'hooks/useLoading';
import { HealthGridTile } from './ProjectHealthGrid.styles';
Expand Down Expand Up @@ -90,7 +89,6 @@ const useProjectResources = (projectId: string) => {
resources: {
members: 0,
apiTokens: 0,
connectedEnvironments: 0,
segments: 0,
},
};
Expand Down Expand Up @@ -130,15 +128,6 @@ export const ProjectResources = () => {
{resources.apiTokens} API key(s)
</ListItem>

<ListItem
linkUrl={`/projects/${projectId}/settings/placeholder`}
linkText='View connections'
icon={<ConnectedIcon />}
>
{resources.connectedEnvironments} connected
environment(s)
</ListItem>

<ListItem
linkUrl={`/projects/${projectId}/settings/segments`}
linkText='Add segments'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const path = (projectId: string) => `api/admin/projects/${projectId}/status`;
const placeholderData: ProjectStatusSchema = {
activityCountByDate: [],
resources: {
connectedEnvironments: 0,
members: 0,
apiTokens: 0,
segments: 0,
Expand Down
5 changes: 0 additions & 5 deletions frontend/src/openapi/models/projectStatusSchemaResources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ export type ProjectStatusSchemaResources = {
* @minimum 0
*/
apiTokens: number;
/**
* The number of environments that have received SDK traffic in this project.
* @minimum 0
*/
connectedEnvironments: number;
/**
* The number of users who have been granted roles in this project. Does not include users who have access via groups.
* @minimum 0
Expand Down
3 changes: 0 additions & 3 deletions src/lib/features/project-status/project-status-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export class ProjectStatusService {

async getProjectStatus(projectId: string): Promise<ProjectStatusSchema> {
const [
connectedEnvironments,
members,
apiTokens,
segments,
Expand All @@ -53,7 +52,6 @@ export class ProjectStatusService {
lifecycleSummary,
staleFlagCount,
] = await Promise.all([
this.projectStore.getConnectedEnvironmentCountForProject(projectId),
this.projectStore.getMembersCountByProject(projectId),
this.apiTokenStore.countProjectTokens(projectId),
this.segmentStore.getProjectSegmentCount(projectId),
Expand All @@ -74,7 +72,6 @@ export class ProjectStatusService {

return {
resources: {
connectedEnvironments,
members,
apiTokens,
segments,
Expand Down
47 changes: 0 additions & 47 deletions src/lib/features/project-status/projects-status.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,51 +127,6 @@ test('project insights should return correct count for each day', async () => {
});
});

test('project status should return environments with connected SDKs', async () => {
const flagName = randomId();
await app.createFeature(flagName);

const envs =
await app.services.environmentService.getProjectEnvironments('default');
expect(envs.some((env) => env.name === 'default')).toBeTruthy();

const appName = 'blah';
const environment = 'default';
await db.stores.clientMetricsStoreV2.batchInsertMetrics([
{
featureName: `flag-doesnt-exist`,
appName,
environment,
timestamp: new Date(),
yes: 5,
no: 2,
},
{
featureName: flagName,
appName: `web2`,
environment,
timestamp: new Date(),
yes: 5,
no: 2,
},
{
featureName: flagName,
appName,
environment: 'not-a-real-env',
timestamp: new Date(),
yes: 2,
no: 2,
},
]);

const { body } = await app.request
.get('/api/admin/projects/default/status')
.expect('Content-Type', /json/)
.expect(200);

expect(body.resources.connectedEnvironments).toBe(1);
});

test('project resources should contain the right data', async () => {
const { body: noResourcesBody } = await app.request
.get('/api/admin/projects/default/status')
Expand All @@ -182,7 +137,6 @@ test('project resources should contain the right data', async () => {
members: 0,
apiTokens: 0,
segments: 0,
connectedEnvironments: 0,
});

const flagName = randomId();
Expand Down Expand Up @@ -239,7 +193,6 @@ test('project resources should contain the right data', async () => {
members: 1,
apiTokens: 1,
segments: 1,
connectedEnvironments: 1,
});
});

Expand Down
2 changes: 0 additions & 2 deletions src/lib/features/project/project-store-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ export interface IProjectStore extends Store<IProject, string> {

getEnvironmentsForProject(id: string): Promise<ProjectEnvironment[]>;

getConnectedEnvironmentCountForProject(id: string): Promise<number>;

getMembersCountByProject(projectId: string): Promise<number>;

getMembersCountByProjectAfterDate(
Expand Down
16 changes: 0 additions & 16 deletions src/lib/features/project/project-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,22 +390,6 @@ class ProjectStore implements IProjectStore {
return rows.map(this.mapProjectEnvironmentRow);
}

async getConnectedEnvironmentCountForProject(id: string): Promise<number> {
const [{ count }] = (await this.db
.countDistinct('cme.environment')
.from('client_metrics_env as cme')
.innerJoin('features', 'cme.feature_name', 'features.name')
.innerJoin('projects', 'features.project', 'projects.id')
.innerJoin(
'project_environments',
'cme.environment',
'project_environments.environment_name',
)
.where('features.project', id)) as { count: string }[];

return Number(count);
}

async getMembersCountByProject(projectId: string): Promise<number> {
const members = await this.db
.from((db) => {
Expand Down
1 change: 0 additions & 1 deletion src/lib/openapi/spec/project-status-schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ test('projectStatusSchema', () => {
{ date: '2022-12-15', count: 5 },
],
resources: {
connectedEnvironments: 2,
apiTokens: 2,
members: 1,
segments: 0,
Expand Down
13 changes: 1 addition & 12 deletions src/lib/openapi/spec/project-status-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,9 @@ export const projectStatusSchema = {
resources: {
type: 'object',
additionalProperties: false,
required: [
'connectedEnvironments',
'apiTokens',
'members',
'segments',
],
required: ['apiTokens', 'members', 'segments'],
description: 'Key resources within the project',
properties: {
connectedEnvironments: {
type: 'integer',
minimum: 0,
description:
'The number of environments that have received SDK traffic in this project.',
},
apiTokens: {
type: 'integer',
minimum: 0,
Expand Down
4 changes: 0 additions & 4 deletions src/test/fixtures/fake-project-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,4 @@ export default class FakeProjectStore implements IProjectStore {
project.id === id ? { ...project, archivedAt: null } : project,
);
}

async getConnectedEnvironmentCountForProject(): Promise<number> {
return 0;
}
}

0 comments on commit a55a956

Please sign in to comment.