Skip to content

Commit aa04397

Browse files
committed
Fix TS not working properly in web-server.
1 parent 5cfd7b3 commit aa04397

File tree

27 files changed

+93
-975
lines changed

27 files changed

+93
-975
lines changed

web-server/pages/api/integrations/github/orgs.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import * as yup from 'yup';
44
import { Endpoint, nullSchema } from '@/api-helpers/global';
55
import { Row, Table } from '@/constants/db';
66
import { selectedDBReposMock } from '@/mocks/github';
7-
import { DB_OrgRepo } from '@/types/resources';
87
import { db } from '@/utils/db';
98

109
const patchSchema = yup.object().shape({
@@ -19,11 +18,11 @@ const endpoint = new Endpoint(nullSchema);
1918
type ReqOrgRepo = { org: string; repos: string[] };
2019
type ReqRepo = { org: string; name: string };
2120

22-
const reqRepoComparator = (reqRepo: ReqRepo) => (tableRepo: DB_OrgRepo) =>
21+
const reqRepoComparator = (reqRepo: ReqRepo) => (tableRepo: Row<'OrgRepo'>) =>
2322
reqRepo.org === tableRepo.org_name && reqRepo.name === tableRepo.name;
24-
const dbRepoComparator = (tableRepo: DB_OrgRepo) => (reqRepo: ReqRepo) =>
23+
const dbRepoComparator = (tableRepo: Row<'OrgRepo'>) => (reqRepo: ReqRepo) =>
2524
reqRepo.org === tableRepo.org_name && reqRepo.name === tableRepo.name;
26-
const dbRepoFilter = (reqRepos: ReqRepo[]) => (tableRepo: DB_OrgRepo) =>
25+
const dbRepoFilter = (reqRepos: ReqRepo[]) => (tableRepo: Row<'OrgRepo'>) =>
2726
reqRepos.some(dbRepoComparator(tableRepo));
2827

2928
endpoint.handle.PATCH(patchSchema, async (req, res) => {

web-server/pages/api/internal/[org_id]/integrations/workflows.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import * as yup from 'yup';
33
import { handleRequest } from '@/api-helpers/axios';
44
import { Endpoint } from '@/api-helpers/global';
55
import { CIProvider, Integration } from '@/constants/integrations';
6-
import { mockWorkflows } from '@/mocks/workflows';
76
import { RepoWorkflowResponse, RepoWorkflow } from '@/types/resources';
87

98
const pathSchema = yup.object().shape({
@@ -20,8 +19,6 @@ const getSchema = yup.object().shape({
2019
const endpoint = new Endpoint(pathSchema);
2120

2221
endpoint.handle.GET(getSchema, async (req, res) => {
23-
if (req.meta?.features?.use_mock_data) return res.send(mockWorkflows);
24-
2522
const { org_id, provider, org_name, repo_name, repo_slug, next_page_token } =
2623
req.payload;
2724

web-server/pages/api/internal/ai/dora_metrics.ts

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ const postSchema = yup.object().shape({
6666
const endpoint = new Endpoint(nullSchema);
6767
endpoint.handle.POST(postSchema, async (req, res) => {
6868
const { data, model, access_token } = req.payload;
69-
const dora_data = data as TeamDoraMetricsApiResponseType;
69+
const dora_data = data as unknown as TeamDoraMetricsApiResponseType;
7070

7171
try {
7272
const [
@@ -76,16 +76,14 @@ endpoint.handle.POST(postSchema, async (req, res) => {
7676
MTTRSummary,
7777
deploymentFrequencySummary,
7878
doraTrendSummary
79-
] = await Promise.all(
80-
[
81-
getDoraMetricsScore,
82-
getLeadTimeSummary,
83-
getCFRSummary,
84-
getMTTRSummary,
85-
getDeploymentFrequencySummary,
86-
getDoraTrendsCorrelationSummary
87-
].map((fn) => fn(dora_data, model, access_token))
88-
);
79+
] = await Promise.all([
80+
getDoraMetricsScore(dora_data, model, access_token),
81+
getLeadTimeSummary(dora_data, model, access_token),
82+
getCFRSummary(dora_data, model, access_token),
83+
getMTTRSummary(dora_data, model, access_token),
84+
getDeploymentFrequencySummary(dora_data, model, access_token),
85+
getDoraTrendsCorrelationSummary(dora_data, model, access_token)
86+
]);
8987

9088
const aggregatedData = {
9189
...doraMetricsScore,
@@ -107,18 +105,28 @@ endpoint.handle.POST(postSchema, async (req, res) => {
107105
...compiledSummary
108106
};
109107

110-
const { status, message } = checkForErrors(responses);
108+
const { status, message } = checkForErrors(
109+
responses as unknown as Record<
110+
string,
111+
{ status: string; message: string }
112+
>
113+
);
111114

112115
if (status === 'error') {
113116
return res.status(400).send({ message });
114117
}
115118

116119
const simplifiedData = Object.fromEntries(
117-
Object.entries(responses).map(([key, value]) => [key, value.data])
120+
Object.entries(responses).map(([key, value]) => [
121+
key,
122+
// TODO: PLEASE FIX THIS TYPE LATER
123+
// @ts-ignore
124+
value.data
125+
])
118126
);
119127

120128
return res.status(200).send(simplifiedData);
121-
} catch (error) {
129+
} catch (error: any) {
122130
return res.status(500).send({
123131
message: 'Internal Server Error',
124132
error: error.message

web-server/pages/api/internal/version.ts

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@ import { Endpoint, nullSchema } from '@/api-helpers/global';
55
const dockerRepoName = 'middlewareeng/middleware';
66
const githubOrgName = 'middlewarehq';
77
const githubRepoName = 'middleware';
8-
const defaultBranch = 'main';
98

109
const endpoint = new Endpoint(nullSchema);
1110

12-
endpoint.handle.GET(nullSchema, async (req, res) => {
11+
endpoint.handle.GET(nullSchema, async (_req, res) => {
1312
return res.send(await checkNewImageRelease());
1413
});
1514

@@ -72,18 +71,6 @@ type TagCompressed = {
7271
digest: string;
7372
};
7473

75-
type GitHubCommit = {
76-
sha: string;
77-
commit: {
78-
author: {
79-
name: string;
80-
email: string;
81-
date: string;
82-
};
83-
message: string;
84-
};
85-
};
86-
8774
function getProjectVersionInfo(): ProjectVersionInfo {
8875
const merge_commit_sha = process.env.MERGE_COMMIT_SHA;
8976
const build_date = process.env.BUILD_DATE;

web-server/pages/api/resources/teams/[team_id]/repos.ts

Lines changed: 0 additions & 34 deletions
This file was deleted.

web-server/pages/api/resources/unassigned_repos.ts

Lines changed: 0 additions & 50 deletions
This file was deleted.

web-server/src/components/ImageUpdateBanner.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ export const Transition = forwardRef(function Transition(
4444
});
4545

4646
export const ImageUpdateBanner = () => {
47-
const theme = useTheme();
4847
const { addModal } = useModal();
4948
const dispatch = useDispatch();
5049

web-server/src/components/PRTable/PrTableWithPrExclusionMenu.tsx

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import { Button, Divider } from '@mui/material';
22
import { useRouter } from 'next/router';
3-
import { FC, useMemo, useCallback, useEffect } from 'react';
3+
import { FC, useCallback, useEffect } from 'react';
44

55
import { PullRequestsTableHeadProps } from '@/components/PRTable/PullRequestsTableHead';
66
import { useModal } from '@/contexts/ModalContext';
77
import { useAuth } from '@/hooks/useAuth';
88
import { useEasyState } from '@/hooks/useEasyState';
9-
import { useFeature } from '@/hooks/useFeature';
109
import { useSingleTeamConfig } from '@/hooks/useStateTeamConfig';
1110
import { updateExcludedPrs, fetchExcludedPrs } from '@/slices/team';
1211
import { useDispatch, useSelector } from '@/store';
1312
import { PR } from '@/types/resources';
13+
import { depFn } from '@/utils/fn';
1414

1515
import { PullRequestsTable } from './PullRequestsTable';
1616

@@ -39,27 +39,25 @@ export const PrTableWithPrExclusionMenu: FC<
3939

4040
dispatch(
4141
updateExcludedPrs({
42-
userId,
4342
teamId,
4443
excludedPrs: [...excludedPrs, ...selectedPrs]
4544
})
46-
).then(() => onUpdateCallback());
45+
).then(() => {
46+
onUpdateCallback();
47+
depFn(selectedPrIds.reset);
48+
});
4749
}, [
4850
dispatch,
4951
excludedPrs,
5052
onUpdateCallback,
5153
propPrs,
54+
selectedPrIds.reset,
5255
selectedPrIds.value,
53-
teamId,
54-
userId
56+
teamId
5557
]);
5658

5759
const isUserRoute = router.pathname.includes('/user');
58-
const isPrExclusionEnabled = useFeature('enable_pr_exclusion');
59-
const enablePrSelection = useMemo(
60-
() => !isUserRoute && isPrExclusionEnabled,
61-
[isPrExclusionEnabled, isUserRoute]
62-
);
60+
const enablePrSelection = !isUserRoute;
6361

6462
useEffect(() => {
6563
dispatch(fetchExcludedPrs({ teamId }));
@@ -70,15 +68,15 @@ export const PrTableWithPrExclusionMenu: FC<
7068
propPrs={propPrs}
7169
selectionMenu={
7270
enablePrSelection && (
73-
<FlexBox>
71+
<FlexBox gap1>
7472
{Boolean(selectedPrIds.value.length) && (
7573
<Button
7674
sx={{ p: 1.5 }}
7775
variant="outlined"
7876
disabled={!selectedPrIds.value.length}
7977
onClick={updateExcludedPrsHandler}
8078
>
81-
Exclude From Team Analytics
79+
Exclude For Team
8280
</Button>
8381
)}
8482
{Boolean(excludedPrs?.length) &&
@@ -111,7 +109,6 @@ export const ExcludedPrTable: FC<{
111109
onUpdateCallback: () => void;
112110
}> = ({ onUpdateCallback }) => {
113111
const dispatch = useDispatch();
114-
const { userId } = useAuth();
115112
const teamId = useSingleTeamConfig().singleTeamId;
116113

117114
const excludedPrs = useSelector((s) => s.team.excludedPrs);
@@ -122,19 +119,11 @@ export const ExcludedPrTable: FC<{
122119
const filteredPrs = excludedPrs.filter((p) => !selectedPrIdsSet.has(p.id));
123120
dispatch(
124121
updateExcludedPrs({
125-
userId,
126122
teamId,
127123
excludedPrs: [...filteredPrs]
128124
})
129125
).then(() => onUpdateCallback());
130-
}, [
131-
dispatch,
132-
excludedPrs,
133-
onUpdateCallback,
134-
selectedPrIds.value,
135-
teamId,
136-
userId
137-
]);
126+
}, [dispatch, excludedPrs, onUpdateCallback, selectedPrIds.value, teamId]);
138127

139128
return (
140129
<FlexBox col gap1>

web-server/src/components/TeamProductionBranchSelector.tsx

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export const TeamProductionBranchSelector: FC<{
5959
}> = ({ onClose }) => {
6060
const dispatch = useDispatch();
6161
const { orgId, integrationSet } = useAuth();
62-
const { team, singleTeamId, dates } = useSingleTeamConfig();
62+
const { singleTeamId, dates } = useSingleTeamConfig();
6363
const branches = useStateBranchConfig();
6464
const isCodeIntegrationLinked = integrationSet.has(IntegrationGroup.CODE);
6565
const isSaving = useEasyState<boolean>(false);
@@ -150,15 +150,12 @@ export const TeamProductionBranchSelector: FC<{
150150
}
151151

152152
const fetchDoraArgs = {
153-
org_id: orgId,
154-
team_id: singleTeamId,
155-
from_date: dates.start,
156-
to_date: dates.end,
153+
orgId: orgId,
154+
teamId: singleTeamId,
155+
fromDate: dates.start,
156+
toDate: dates.end,
157157
branches:
158-
activeBranchMode === ActiveBranchMode.PROD ? null : branches,
159-
manager_teams_array: [
160-
{ team_ids: [singleTeamId], manager_id: team?.manager_id }
161-
]
158+
activeBranchMode === ActiveBranchMode.PROD ? null : branches
162159
};
163160
await dispatch(fetchTeamDoraMetrics(fetchDoraArgs));
164161
enqueueSnackbar('Updated Successfully', {
@@ -189,7 +186,6 @@ export const TeamProductionBranchSelector: FC<{
189186
dates.start,
190187
dates.end,
191188
branches,
192-
team?.manager_id,
193189
enqueueSnackbar,
194190
updateActiveProdBranch
195191
]

web-server/src/constants/db.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,17 @@ export const Columns = {
540540
anonymous
541541
}
542542
return Columns;
543+
}),
544+
[Table.TeamRelations]: objectEnumFromFn(() => {
545+
enum Columns {
546+
created_at,
547+
updated_at,
548+
user_id,
549+
relation,
550+
related_user_id,
551+
org_id
552+
}
553+
return Columns;
543554
})
544555
};
545556

0 commit comments

Comments
 (0)