Skip to content

Commit

Permalink
Merge pull request #239 from NUS-CRISP/staging
Browse files Browse the repository at this point in the history
Staging
  • Loading branch information
dexter-sim authored Oct 17, 2024
2 parents 6edf90e + dc741af commit b9a982b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
20 changes: 11 additions & 9 deletions backend/jobs/trofosJob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import {
} from '@models/JiraData';
import { JiraBoard, JiraIssue, JiraSprint } from '@shared/types/JiraData';
import {
TROFOS_COURSE_URI,
TROFOS_PROJECT_URI,
TROFOS_COURSE_PATH,
TROFOS_PROJECT_PATH,
TROFOS_SPRINT_PATH,
} from '../utils/endpoints';

Expand All @@ -25,8 +25,9 @@ const fetchAndSaveTrofosData = async () => {
continue;
}

const trofosCourseUri = `${process.env.TROFOS_URI}${TROFOS_COURSE_PATH}`;
try {
const trofosCourseResponse = await fetch(TROFOS_COURSE_URI, {
const trofosCourseResponse = await fetch(trofosCourseUri, {
method: 'GET',
headers: {
'x-api-key': apiKey,
Expand All @@ -45,8 +46,9 @@ const fetchAndSaveTrofosData = async () => {
console.error('Error in fetching Trofos course:', error);
}

const trofosProjectUri = `${process.env.TROFOS_URI}${TROFOS_PROJECT_PATH}`;
try {
const trofosProjectResponse = await fetch(TROFOS_PROJECT_URI, {
const trofosProjectResponse = await fetch(trofosProjectUri, {
method: 'GET',
headers: {
'x-api-key': apiKey,
Expand Down Expand Up @@ -81,7 +83,7 @@ const fetchSingleTrofosProject = async (
trofosProjectId: number,
apiKey: string
) => {
const singleTrofosProjectUri = `${TROFOS_PROJECT_URI}/${trofosProjectId}`;
const singleTrofosProjectUri = `${process.env.TROFOS_URI}${TROFOS_PROJECT_PATH}/${trofosProjectId}`;

try {
const singleTrofosProjectResponse = await fetch(singleTrofosProjectUri, {
Expand Down Expand Up @@ -145,7 +147,7 @@ const fetchSprintsFromSingleTrofosProject = async (
trofosProjectId: number,
apiKey: string
) => {
const trofosSprintUri = `${TROFOS_PROJECT_URI}/${trofosProjectId}${TROFOS_SPRINT_PATH}`;
const trofosSprintUri = `${process.env.TROFOS_URI}${TROFOS_PROJECT_PATH}/${trofosProjectId}${TROFOS_SPRINT_PATH}`;

try {
const trofosSprintResponse = await fetch(trofosSprintUri, {
Expand Down Expand Up @@ -194,7 +196,7 @@ const fetchSprintsFromSingleTrofosProject = async (
}
);

const boardSelfUri = `${TROFOS_PROJECT_URI}/${trofosProjectId}`;
const boardSelfUri = `${process.env.TROFOS_URI}${TROFOS_PROJECT_PATH}/${trofosProjectId}`;
await JiraBoardModel.findOneAndUpdate(
{ self: boardSelfUri },
{ $push: { jiraSprints: sprint._id } },
Expand Down Expand Up @@ -222,7 +224,7 @@ const saveBacklogToDatabase = async (trofosSprintData: any) => {

// Iterate through each backlog item in the sprint
for (const backlog of backlogItems) {
const trofosSprintUri = `${TROFOS_PROJECT_URI}/${sprint.project_id}${TROFOS_SPRINT_PATH}/${sprint.id}`;
const trofosSprintUri = `${process.env.TROFOS_URI}${TROFOS_PROJECT_PATH}/${sprint.project_id}${TROFOS_SPRINT_PATH}/${sprint.id}`;

const transformedBacklog: Omit<JiraIssue, '_id'> = {
id: backlog.backlog_id, // Assuming 'backlog_id' is the equivalent of 'id'
Expand Down Expand Up @@ -255,7 +257,7 @@ const saveBacklogToDatabase = async (trofosSprintData: any) => {
}
);

const boardSelfUri = `${TROFOS_PROJECT_URI}/${backlog.project_id}`;
const boardSelfUri = `${process.env.TROFOS_URI}${TROFOS_PROJECT_PATH}/${backlog.project_id}`;
await JiraBoardModel.findOneAndUpdate(
{ self: boardSelfUri },
{ $push: { jiraIssues: issue._id } },
Expand Down
6 changes: 2 additions & 4 deletions backend/utils/endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ export const BOARD_API_PATH = '/rest/agile/1.0/board';
export const ISSUE_API_PATH = '/rest/agile/1.0/issue';

/*---------------------------------------Trofos---------------------------------------*/
export const TROFOS_COURSE_URI =
'https://trofos-production.comp.nus.edu.sg/api/external/v1/course';
export const TROFOS_PROJECT_URI =
'https://trofos-production.comp.nus.edu.sg/api/external/v1/project';
export const TROFOS_COURSE_PATH = '/course';
export const TROFOS_PROJECT_PATH = '/project';
export const TROFOS_SPRINT_PATH = '/sprint';

0 comments on commit b9a982b

Please sign in to comment.