Skip to content

Commit

Permalink
#291 : better name & clean console
Browse files Browse the repository at this point in the history
  • Loading branch information
guillermau committed Mar 7, 2025
1 parent 50068bc commit 273f7b9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion api/src/core/adapters/GitLab/api/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const getLastMergeRequest = async (projectUrl: string) => {
return getApiCallTakeFirst<MergeRequestSchema>(`${projectUrl}/merge_requests?state=closed&sort=desc`);
};

export const projectEndpointMaker = (repoUrl: string | URL) => {
export const projectGitLabApiMaker = (repoUrl: string | URL) => {
const apiProjectEndpoint = repoUrlToAPIUrl(repoUrl);

return {
Expand Down
20 changes: 11 additions & 9 deletions api/src/core/adapters/hal/getHalSoftwareExternalData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { HalFetchError } from "./HalAPI/type";
import { SILL } from "../../../types/SILL";
import { HAL } from "./types/HAL";
import { repoAnalyser, RepoType } from "../../../tools/repoAnalyser";
import { projectEndpointMaker } from "../GitLab/api/project";
import { projectGitLabApiMaker } from "../GitLab/api/project";

const buildParentOrganizationTree = async (
structureIdArray: number[] | string[] | undefined
Expand Down Expand Up @@ -222,17 +222,19 @@ export const getHalSoftwareExternalData: GetSoftwareExternalData = memoize(
const getRepoMetadata = async (repoType: RepoType | undefined) => {
switch (repoType) {
case "GitLab":
const apiProject = projectEndpointMaker(halRawSoftware?.softCodeRepository_s?.[0]);
const lastCommit = await apiProject.commits.getLastCommit();
const lastIssue = await apiProject.issues.getLastClosedIssue();
const lastMergeRequest = await apiProject.mergeRequests.getLast();
const gitLabProjectapi = projectGitLabApiMaker(halRawSoftware?.softCodeRepository_s?.[0]);
const lastGLCommit = await gitLabProjectapi.commits.getLastCommit();
const lastFLIssue = await gitLabProjectapi.issues.getLastClosedIssue();
const lastGLMergeRequest = await gitLabProjectapi.mergeRequests.getLast();
return {
healthCheck: {
lastCommit: lastCommit ? new Date(lastCommit.created_at).valueOf() : undefined,
lastCommit: lastGLCommit ? new Date(lastGLCommit.created_at).valueOf() : undefined,
lastClosedIssue:
lastIssue && lastIssue.closed_at ? new Date(lastIssue.closed_at).valueOf() : undefined,
lastClosedIssuePullRequest: lastMergeRequest
? new Date(lastMergeRequest.updated_at).valueOf()
lastFLIssue && lastFLIssue.closed_at
? new Date(lastFLIssue.closed_at).valueOf()
: undefined,
lastClosedIssuePullRequest: lastGLMergeRequest
? new Date(lastGLMergeRequest.updated_at).valueOf()
: undefined
}
};
Expand Down
3 changes: 0 additions & 3 deletions api/src/tools/repoAnalyser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ export const repoAnalyser = async (url: string | URL | undefined): Promise<RepoT
return undefined;
}

const test = urlObj.origin;
console.log(test);

if (urlObj.origin === "https://github.com") {
return "GitHub";
}
Expand Down

0 comments on commit 273f7b9

Please sign in to comment.