Skip to content

Commit

Permalink
refactor: removed not needed code
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniomuso committed Jun 12, 2023
1 parent 8e644e3 commit b8eb7ff
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,14 @@ export const IssuesTable = ({}) => {
if (!projectDetails)
throw new Error('wrong project_slug or project_id');

const projectId = project_id || projectDetails.id;
const summary = await GitlabCIAPI.getIssuesSummary(projectDetails.id);

const [summary, projectName] = await Promise.all([
GitlabCIAPI.getIssuesSummary(projectId),
GitlabCIAPI.getProjectName(projectId),
]);

if (!summary || !projectName) {
throw new Error('project name or gitlab issues are undefined!');
if (!summary) {
throw new Error('gitlab issues is undefined!');
}
const renderData = {
data: summary,
projectName,
projectName: projectDetails.name,
};

return renderData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ export const LanguagesCard = ({}) => {
if (!projectDetails)
throw new Error('wrong project_slug or project_id');

const projectId = project_id || projectDetails.id;
const summary = await GitlabCIAPI.getLanguagesSummary(projectId);
const summary = await GitlabCIAPI.getLanguagesSummary(
projectDetails.id
);
if (!summary) throw new Error('Languages summary is not defined!');

return summary;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,12 @@ const MergeRequestStats = (props: Props) => {
);
if (!projectDetails)
throw new Error('wrong project_slug or project_id');
const projectId = project_id || projectDetails.id;

const mergeRequestStatusData =
await GitlabCIAPI.getMergeRequestsStatusSummary(projectId, count);
await GitlabCIAPI.getMergeRequestsStatusSummary(
projectDetails.id,
count
);

if (!mergeRequestStatusData)
throw new Error('getMergeRequestsStatusSummary error');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,13 @@ export const MergeRequestsTable = ({}) => {
if (!projectDetails)
throw new Error('wrong project_slug or project_id');

const projectId = project_id || projectDetails.id;

const [summary, projectName] = await Promise.all([
GitlabCIAPI.getMergeRequestsSummary(projectId),
GitlabCIAPI.getProjectName(projectId),
]);
const summary = await GitlabCIAPI.getMergeRequestsSummary(
projectDetails.id
);

if (!summary || !projectName)
throw new Error(
'Merge request summary or project_name are undefined!'
);
if (!summary) throw new Error('Merge request summary is undefined!');

return { data: summary, projectName };
return { data: summary, projectName: projectDetails.name };
}, []);

if (loading) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,15 @@ export const PeopleCard = ({}) => {
if (!projectDetails)
throw new Error('wrong project_slug or project_id');

const projectId = project_id || projectDetails.id;

const contributorData = await GitlabCIAPI.getContributorsSummary(
projectId
projectDetails.id
);

// CODE OWNERS
let codeOwners: PeopleCardEntityData[] | undefined = [];
try {
codeOwners = await GitlabCIAPI.getCodeOwners(
projectId,
projectDetails.id,
projectDetails?.default_branch,
codeowners_path
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,11 @@ export const PipelinesTable = ({}) => {
);
if (!projectDetails)
throw new Error('wrong project_slug or project_id');
const projectId = project_id || projectDetails.id;

const [summary, projectName] = await Promise.all([
GitlabCIAPI.getPipelineSummary(projectId),
GitlabCIAPI.getProjectName(projectId),
]);
const summary = await GitlabCIAPI.getPipelineSummary(projectDetails.id);

if (!summary || !projectName)
throw new Error(
'Merge request summary or project_name are undefined!'
);
return { summary, projectName };
if (!summary) throw new Error('Merge request summary is undefined!');
return { summary, projectName: projectDetails.name };
}, []);

if (loading) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,10 @@ export const ReadmeCard = ({}) => {
if (!projectDetails)
throw new Error('wrong project_slug or project_id');

const projectId = project_id || projectDetails.id;
let readmeData: string | undefined = undefined;
try {
readmeData = await GitlabCIAPI.getReadme(
projectId,
projectDetails.id,
projectDetails.default_branch,
readme_path
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,9 @@ export const ReleasesCard = (props: ReleasesCardProps) => {
if (!projectDetails)
throw new Error('wrong project_slug or project_id');

const projectId = project_id || projectDetails.id;
const releaseData = await GitlabCIAPI.getReleasesSummary(projectId);
const releaseData = await GitlabCIAPI.getReleasesSummary(
projectDetails.id
);

if (!releaseData) throw new Error('Release data are undefined!');

Expand Down

0 comments on commit b8eb7ff

Please sign in to comment.