Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert Data Visauliztion #242

Closed
wants to merge 108 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
e0d7c49
fix: tutorial popover issue
wxy1203 Sep 7, 2024
363853b
fix: home page contact us
wxy1203 Sep 14, 2024
ec49f4a
Update course schema to store GitHub repository links in an array
dexter-sim Sep 23, 2024
429a5ed
Add front end Repository page and GET API call to retrieve GitHub rep…
dexter-sim Sep 24, 2024
b8183fe
Update RepositoryInfo.tsx
dexter-sim Sep 24, 2024
34e13d4
Implement add GitHub Repo Link API and functionality
dexter-sim Sep 24, 2024
c3dc3b0
Update OverviewCard.tsx
wxy1203 Sep 25, 2024
d7ce8ea
Update Analytics.tsx
wxy1203 Sep 25, 2024
464c770
Create AllTeams.tsx
wxy1203 Sep 25, 2024
53c26fd
Update Analytics.tsx
wxy1203 Sep 25, 2024
fd1b944
Update AllTeams.tsx
wxy1203 Sep 25, 2024
617e84c
Update Analytics.tsx
wxy1203 Sep 25, 2024
83f2d3a
Update AllTeams.tsx
wxy1203 Sep 25, 2024
36b795d
Update Analytics.tsx
wxy1203 Sep 25, 2024
c07dbbf
Update AllTeams.tsx
wxy1203 Sep 25, 2024
18066f2
Update Analytics.tsx
wxy1203 Sep 25, 2024
6b46f02
Update AllTeams.tsx
wxy1203 Sep 25, 2024
72a0727
Update Overview.tsx
wxy1203 Sep 25, 2024
b21286b
Update AllTeams.tsx
wxy1203 Sep 25, 2024
406f48d
Update Overview.tsx
wxy1203 Sep 25, 2024
83d0816
Update AllTeams.tsx
wxy1203 Sep 25, 2024
c19f06a
Update Overview.tsx
wxy1203 Sep 25, 2024
8884d8b
Update AllTeams.tsx
wxy1203 Sep 25, 2024
8b73bdf
Update AllTeams.tsx
wxy1203 Sep 25, 2024
51f740b
Update AllTeams.tsx
wxy1203 Sep 25, 2024
ac174c0
fix: create course form
wxy1203 Sep 25, 2024
28b4af3
fix: create course form
wxy1203 Sep 25, 2024
9d12500
Update AllTeams.tsx
wxy1203 Sep 26, 2024
9f518b5
feat: unable to navigate before adding people
wxy1203 Sep 26, 2024
c69dab0
fix: prettier check
wxy1203 Sep 26, 2024
ad75e40
feat: need to add people first
wxy1203 Sep 26, 2024
e89b298
Update PeopleInfo.tsx
wxy1203 Sep 26, 2024
c9bd128
Update Navbar.tsx
wxy1203 Sep 26, 2024
347e09e
Update .gitignore
wxy1203 Sep 27, 2024
e0a3aab
Update package.json
wxy1203 Sep 27, 2024
0da6afb
Update package.json
wxy1203 Sep 27, 2024
22cb0df
controller, routes, service for code analysis
rjkoh Oct 4, 2024
1fe3fa7
add tests for code analysis, fix github service test
rjkoh Oct 4, 2024
9cc01e5
add basic UI and backend for TA permission
rjkoh Oct 9, 2024
7f2bec5
style fixing
rjkoh Oct 9, 2024
8d21e75
remove code analysis frontend redundancies
rjkoh Oct 9, 2024
aa86d52
frontend: group code analyses by team number and time
rjkoh Oct 9, 2024
fc0eb1d
fix: environment change
wxy1203 Oct 9, 2024
6b4305e
feat: add class overview in nav bar
wxy1203 Oct 9, 2024
82bde4c
feat: data visualization in class overview
wxy1203 Oct 9, 2024
99b8866
feat: class overview data viz (2 charts)
wxy1203 Oct 9, 2024
8f0ca2e
feat: nav bar icon
wxy1203 Oct 10, 2024
d89fe7b
fix: scroll bar for course
wxy1203 Oct 10, 2024
3040d6f
fix: eslint
wxy1203 Oct 10, 2024
24f1bae
fix: eslint
wxy1203 Oct 10, 2024
771af98
fix: eslint
wxy1203 Oct 10, 2024
a2538d3
fix: eslint
wxy1203 Oct 10, 2024
4a08301
fix: eslint
wxy1203 Oct 10, 2024
6346123
fix: remove node modules
wxy1203 Oct 10, 2024
9cc788e
Merge pull request #227 from NUS-CRISP/staging
wxy1203 Oct 10, 2024
5fbf534
fix: delete env file
wxy1203 Oct 10, 2024
51f5d30
fix: delete env files
wxy1203 Oct 10, 2024
6c67f7d
Update .gitignore
wxy1203 Oct 10, 2024
4e20898
Merge branch 'staging' into non-github-orgs
dexter-sim Oct 12, 2024
a491645
Add functionality to delete repository
dexter-sim Oct 12, 2024
a2c8956
Add functionality to edit repository links
dexter-sim Oct 13, 2024
e766b74
Merge branch 'staging' into non-github-orgs
dexter-sim Oct 13, 2024
0343d6f
add overview for code analysis frontend
rjkoh Oct 15, 2024
013375b
fix scroll overflow on codeanalysis
rjkoh Oct 15, 2024
0e42442
add timeline view
rjkoh Oct 15, 2024
9193332
add prettier
rjkoh Oct 15, 2024
beb64a6
style fixes
rjkoh Oct 15, 2024
05b9b0e
style fixes
rjkoh Oct 15, 2024
6a7ba60
style
rjkoh Oct 15, 2024
2157f83
Merge branch 'staging' into non-github-orgs
dexter-sim Oct 15, 2024
de502c9
Create fetch job for public GitHub repositories
dexter-sim Oct 15, 2024
4551959
Add unit test for getRepositories in course controller
dexter-sim Oct 17, 2024
b18f25b
Add unit tests for add, edit, and remove repository for course contro…
dexter-sim Oct 17, 2024
3f5ab7b
mkdir before clone
rjkoh Oct 18, 2024
18895b5
style
rjkoh Oct 18, 2024
beb20ad
handle private repos
rjkoh Oct 18, 2024
4eac941
style
rjkoh Oct 18, 2024
22a5d65
Merge branch 'staging' into code-analysis-backend
rjkoh Oct 18, 2024
2de0b15
follow RUN_JOB_NOW
rjkoh Oct 18, 2024
f7885c8
style
rjkoh Oct 18, 2024
0dfcd02
fix backend imports
rjkoh Oct 18, 2024
a8796c1
Add unit tests for GitHub repositories API for course service
dexter-sim Oct 18, 2024
6d2f12e
Fix formatting
dexter-sim Oct 18, 2024
11a91a0
Remove repeated attempts for code frequency stats
dexter-sim Oct 19, 2024
8008e84
feat: filter the team by teamset
wxy1203 Oct 21, 2024
54f5ae9
update
wxy1203 Oct 21, 2024
0d81b08
update
wxy1203 Oct 21, 2024
bd4ee58
Merge branch 'staging' into non-github-orgs
dexter-sim Oct 21, 2024
79be9a1
feat: class_overview and team_review
wxy1203 Oct 22, 2024
0e9159c
feat: team review - milestone and issue tracker
wxy1203 Oct 22, 2024
16a13d7
Update jira.png
wxy1203 Oct 23, 2024
3dbaba7
feat: class overview
wxy1203 Oct 23, 2024
b08a94c
feat: weekly addition and deletion
wxy1203 Oct 23, 2024
07869b7
feat: team review-individual
wxy1203 Oct 23, 2024
8e1570e
fix: eslint
wxy1203 Oct 23, 2024
0a423e1
fix: eslint
wxy1203 Oct 23, 2024
a87929c
fix: eslint
wxy1203 Oct 23, 2024
050edcf
fix: eslint
wxy1203 Oct 23, 2024
5bc43e3
feat: eslint
wxy1203 Oct 23, 2024
21e5c80
Update Navbar.tsx
wxy1203 Oct 25, 2024
ce73b4b
Update cron job for non github orgs repositories
dexter-sim Oct 26, 2024
1615ac1
Use generic Octokit for non GitHub App installed owners
dexter-sim Oct 26, 2024
c100d3d
Merge pull request #225 from rjkoh/code-analysis-backend
rjkoh Nov 11, 2024
b61db60
Merge pull request #211 from NUS-CRISP/non-github-orgs
dexter-sim Nov 18, 2024
c1f5ed5
Merge branch 'staging' into data-viz
wxy1203 Nov 18, 2024
e41383a
fix: bugs
wxy1203 Nov 23, 2024
2278a82
fix: eslint
wxy1203 Nov 23, 2024
36933eb
fix: eslint
wxy1203 Nov 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions backend/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import metricRoutes from './routes/metricRoutes';
import teamRoutes from './routes/teamRoutes';
import teamSetRoutes from './routes/teamSetRoutes';
import userRoutes from './routes/userRoutes';
import codeAnalysisRoutes from './routes/codeAnalysisRoutes';
import { connectToDatabase } from './utils/database';

const env = process.env.NODE_ENV ?? 'development';
Expand Down Expand Up @@ -44,6 +45,7 @@ app.use('/api/assessments', assessmentRoutes);
app.use('/api/jira', jiraRoutes);
app.use('/api/metrics', metricRoutes);
app.use('/api/user', userRoutes);
app.use('/api/codeanalysis', codeAnalysisRoutes);

app.listen(port, () => {
console.log(`Server is running at http://localhost:${port}`);
Expand Down
66 changes: 66 additions & 0 deletions backend/controllers/codeAnalysisController.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { Request, Response } from 'express';
import {
fetchAllCodeAnalysisData,
fetchAllCodeAnalysisDataForOrg,
getAuthorizedCodeAnalysisDataByCourse,
} from '../services/codeAnalysisService';
import { MissingAuthorizationError, NotFoundError } from '../services/errors';
import { getAccountId } from '../utils/auth';

export const getAllCodeAnalysisData = async (req: Request, res: Response) => {
try {
const codeAnalysisData = await fetchAllCodeAnalysisData();
return res.status(200).json({ codeAnalysisData });
} catch (error) {
console.error('Error retrieving all code analysis data:', error);
return res
.status(500)
.json({ error: 'Failed to get all code analysis data' });
}
};

export const getAllCodeAnalysisDataByOrg = async (
req: Request,
res: Response
) => {
try {
const codeAnalysisDataas = await fetchAllCodeAnalysisDataForOrg(
req.params.gitHubOrgName
);
return res.status(200).json(codeAnalysisDataas);
} catch (error) {
if (error instanceof NotFoundError) {
res.status(404).json({ message: error.message });
} else {
console.error('Error retrieving code analysis datas for org:', error);
return res
.status(500)
.json({ error: 'Failed to get code analysis datas for org' });
}
}
};

export const getAllCodeAnalysisDataByCourse = async (
req: Request,
res: Response
) => {
const courseId = req.params.id;

Check warning on line 47 in backend/controllers/codeAnalysisController.ts

View check run for this annotation

Codecov / codecov/patch

backend/controllers/codeAnalysisController.ts#L47

Added line #L47 was not covered by tests

try {
const accountId = await getAccountId(req);
const codeAnalyses = await getAuthorizedCodeAnalysisDataByCourse(

Check warning on line 51 in backend/controllers/codeAnalysisController.ts

View check run for this annotation

Codecov / codecov/patch

backend/controllers/codeAnalysisController.ts#L49-L51

Added lines #L49 - L51 were not covered by tests
accountId,
courseId
);
res.status(200).json(codeAnalyses);

Check warning on line 55 in backend/controllers/codeAnalysisController.ts

View check run for this annotation

Codecov / codecov/patch

backend/controllers/codeAnalysisController.ts#L55

Added line #L55 was not covered by tests
} catch (error) {
if (error instanceof NotFoundError) {
res.status(404).json({ error: error.message });

Check warning on line 58 in backend/controllers/codeAnalysisController.ts

View check run for this annotation

Codecov / codecov/patch

backend/controllers/codeAnalysisController.ts#L58

Added line #L58 was not covered by tests
} else if (error instanceof MissingAuthorizationError) {
res.status(400).json({ error: 'Missing authorization' });

Check warning on line 60 in backend/controllers/codeAnalysisController.ts

View check run for this annotation

Codecov / codecov/patch

backend/controllers/codeAnalysisController.ts#L60

Added line #L60 was not covered by tests
} else {
console.error('Error fetching teams:', error);
res.status(500).json({ error: 'Failed to fetch code analyses' });

Check warning on line 63 in backend/controllers/codeAnalysisController.ts

View check run for this annotation

Codecov / codecov/patch

backend/controllers/codeAnalysisController.ts#L62-L63

Added lines #L62 - L63 were not covered by tests
}
}
};
72 changes: 72 additions & 0 deletions backend/controllers/courseController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import { addAssessmentsToCourse } from '../services/assessmentService';
import {
addFacultyToCourse,
addMilestoneToCourse,
addRepositoriesToCourse,
addSprintToCourse,
addStudentsToCourse,
addTAsToCourse,
createNewCourse,
deleteCourseById,
editRepository,
getAssessmentsFromCourse,
getCourseById,
getCourseCodeById,
Expand All @@ -17,9 +19,11 @@ import {
getCoursesForUser,
getPeopleFromCourse,
getProjectManagementBoardFromCourse,
getRepositoriesFromCourse,
getTeamSetNamesFromCourse,
getTeamSetsFromCourse,
removeFacultyFromCourse,
removeRepositoryFromCourse,
removeStudentsFromCourse,
removeTAsFromCourse,
updateCourseById,
Expand Down Expand Up @@ -323,6 +327,74 @@ export const getPeople = async (req: Request, res: Response) => {
}
};

/*-------------------------------------Repositories-------------------------------------*/
export const getRepositories = async (req: Request, res: Response) => {
const courseId = req.params.id;
try {
const repositories = await getRepositoriesFromCourse(courseId);
res.status(200).json(repositories);
} catch (error) {
if (error instanceof NotFoundError) {
res.status(404).json({ error: error.message });
} else {
console.error('Error fetching repositories:', error);
res.status(500).json({ error: 'Failed to retrieve repositories' });
}
}
};

export const addRepositories = async (req: Request, res: Response) => {
const courseId = req.params.id;
const repositories = req.body.items;
try {
await addRepositoriesToCourse(courseId, repositories);
res
.status(200)
.json({ message: 'Repositories added to the course successfully' });
} catch (error) {
if (error instanceof NotFoundError) {
res.status(404).json({ error: error.message });
} else {
console.error('Error adding repositories:', error);
res.status(500).json({ error: 'Failed to add repositories' });
}
}
};

export const updateRepository = async (req: Request, res: Response) => {
const { id, repositoryIndex } = req.params;
const updateData = req.body;

try {
await editRepository(id, Number(repositoryIndex), updateData);
res.status(200).json({ message: 'Repository updated successfully' });
} catch (error) {
if (error instanceof NotFoundError) {
res.status(404).json({ error: error.message });
} else {
console.error('Error editing repository:', error);
res.status(500).json({ error: 'Failed to update repository' });
}
}
};

export const removeRepository = async (req: Request, res: Response) => {
const { id, repositoryIndex } = req.params;
try {
await removeRepositoryFromCourse(id, Number(repositoryIndex));
res
.status(200)
.json({ message: 'Repository removed from the course successfully' });
} catch (error) {
if (error instanceof NotFoundError) {
res.status(404).json({ error: error.message });
} else {
console.error('Error removing repository:', error);
res.status(500).json({ error: 'Failed to remove repository' });
}
}
};

/*----------------------------------------TeamSet----------------------------------------*/
export const addTeamSet = async (req: Request, res: Response) => {
const courseId = req.params.id;
Expand Down
38 changes: 27 additions & 11 deletions backend/jobs/codeAnalysisJob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const getCourseCodeData = async (octokit: Octokit, course: any) => {

await createProjectIfNotExists(gitHubOrgName + '_' + repo.name);

await getLatestCommit(gitHubOrgName, repo.name);
await getLatestCommit(octokit, gitHubOrgName, repo, course);

await scanRepo(gitHubOrgName, repo.name, buildTool);

Expand Down Expand Up @@ -175,26 +175,42 @@ const createProjectIfNotExists = async (repo: string) => {
}
};

const getLatestCommit = async (gitHubOrgName: string, repoName: string) => {
const getLatestCommit = async (
octokit: Octokit,
gitHubOrgName: string,
repo: any,
course: any
) => {
try {
const repoPath = path.join(
process.env.REPO_PATH || '',
gitHubOrgName,
repoName
repo.name
);

const installationTokenResponse =
await octokit.rest.apps.createInstallationAccessToken({
installation_id: course.installationId,
});
const installationToken = installationTokenResponse.data.token;

const cloneUrl = `https://oauth2:${installationToken}@github.com/${gitHubOrgName}/${repo.name}.git`;

if (!fs.existsSync(repoPath)) {
console.log(`Cloning repository ${repoName}...`);
await execShellCommand(
`git clone https://github.com/${gitHubOrgName}/${repoName}.git ${repoPath}`
);
fs.mkdirSync(repoPath, { recursive: true });
}

if (!fs.existsSync(path.join(repoPath, '.git'))) {
console.log(`Cloning repository ${repo.name}...`);
fs.rmSync(repoPath, { recursive: true, force: true });
fs.mkdirSync(repoPath, { recursive: true });
await execShellCommand(`git clone ${cloneUrl} ${repoPath}`);
} else {
await execShellCommand(`git -C ${repoPath} pull`);
console.log(`Pulling repository ${repo.name}`);
await execShellCommand(`git -C ${repoPath} pull ${cloneUrl}`);
}
} catch (error) {
console.error(
`Error updating repository ${repoName}: ${(error as Error).message}`
);
console.error(`Error updating repository ${repo.name}: ${error}`);
}
};

Expand Down
Loading