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

Fix Object Serialization, Proposal to improve Database-Scheme, #62

Merged
merged 55 commits into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
a46f6fd
added basic classes without functionality
SirJonithan Jan 26, 2025
2e1d6ad
added missing changes
SirJonithan Jan 26, 2025
60d5f7d
Merge pull request #1 from riehlegroup/main
JudithWell Jan 30, 2025
9870833
minor changes
SirJonithan Feb 2, 2025
491831f
Implementation of relevant classes has begun, writer classes are pret…
JudithWell Feb 3, 2025
cf7e295
adapted ProjectManager for new database scheme and naming conventions
SirJonithan Feb 4, 2025
dbd0d76
updated projectFeatures for new databaseScheme
SirJonithan Feb 4, 2025
02713eb
updated UserConfig for new database scheme
SirJonithan Feb 4, 2025
d969b70
updated server to call the correct methods
SirJonithan Feb 4, 2025
7381664
Added databaseInitializer.ts (with updated scheme) and reworked proje…
JudithWell Feb 5, 2025
2f5a7db
implemented fixes for CourseProject
SirJonithan Feb 5, 2025
96aa543
added individual add/remove methods for projects
SirJonithan Feb 5, 2025
b9e1ca6
renamed projectGroup to course in all client api requests
SirJonithan Feb 5, 2025
00599f7
Reworked Server db interface
JudithWell Feb 5, 2025
20f398a
renamed some more client variables.
JudithWell Feb 5, 2025
ebec9cc
Merge branch 'fix-db' of github.com:SirJonithan/mini-meco into riehle…
SirJonithan Feb 7, 2025
0d8ff9c
resolved merge-conflicts
SirJonithan Feb 7, 2025
b48809f
updated missing file
SirJonithan Feb 7, 2025
e6aa2ac
Tiny changes prior to pr of updates from origin.
JudithWell Feb 8, 2025
af32490
Merge pull request #2 from riehlegroup/main
JudithWell Feb 8, 2025
1080825
Moved all serializer related classes into its own folder, to separate…
JudithWell Feb 8, 2025
dc770af
Caught remaining merge error in course.ts
JudithWell Feb 8, 2025
38270b0
Made a method to get table name from class and adjusted some naming, …
JudithWell Feb 8, 2025
cd24a48
Merge branch 'main' into fix-db
JudithWell Feb 8, 2025
88c6f06
Merge pull request #3 from SirJonithan/fix-db
JudithWell Feb 8, 2025
fdaefa3
Added Serialization to Admin, Course, CourseProject, ProjectMember
JudithWell Feb 8, 2025
9165df3
Added ID based writeObject to Writer classes.
JudithWell Feb 8, 2025
825f0d0
Extended DatabaseSerializableFactory for more Serializable Types.
JudithWell Feb 8, 2025
bb319cf
Implemented Reader, DatabaseReader. Especially fixed readObject id-wi…
JudithWell Feb 8, 2025
7db401f
Applied Serializer in auth.ts and allowed null values to be set, read…
JudithWell Feb 8, 2025
717c506
Adjusted databaseInitializer according to Serializer Pattern. Also ad…
JudithWell Feb 8, 2025
6ff93c4
Added Object queueing to read related Entities recursively.
JudithWell Feb 8, 2025
511ab99
Removed setId() from User, IDs should not be manually changeable!
JudithWell Feb 8, 2025
29cdb50
Added wasHandled to track handled objects. Also Added further classes…
JudithWell Feb 8, 2025
1c3044e
Added Project Membership types for readonly access to user_projects d…
JudithWell Feb 8, 2025
5a36be5
Added Object tracking to Reader to avoid reading the same object mult…
JudithWell Feb 9, 2025
2119b04
Added Project Manager to manage Project memberships. Also removed any…
JudithWell Feb 9, 2025
16de85a
Moved ProjectManager out of Models
JudithWell Feb 9, 2025
bbda41d
Started testing. Fixed a bug caused by passing tablename as parameter.
JudithWell Feb 9, 2025
88bb6e1
Fixed a bug: Typo in githubUsername attribute name.
JudithWell Feb 9, 2025
7832594
Fixed two typos in ObjectHandler
JudithWell Feb 9, 2025
b8d8e48
Fixed a bug with asynchronicity which cause very weird behaviour.
JudithWell Feb 9, 2025
dc27c8a
Added a couple more managers that supply a create method for Users, C…
JudithWell Feb 9, 2025
bfeab09
moved projects query into CourseManager
SirJonithan Feb 9, 2025
4e4a35a
removed console.log statements
SirJonithan Feb 9, 2025
f37eb94
fixed problem with not awaiting the result
SirJonithan Feb 9, 2025
a0c6470
Merge branch 'main' into main
JudithWell Feb 11, 2025
56fa22f
Runs semester test aswell now
JudithWell Feb 15, 2025
a40abaf
Added ResultSetTypes to not have to use any anymore.
JudithWell Feb 15, 2025
823776b
Removed some unused commented out code lines.
JudithWell Feb 15, 2025
17ef3b0
Removed unused Codelines.
JudithWell Feb 15, 2025
442207e
Merge branch 'main' into main
JudithWell Feb 15, 2025
5a61144
Fixed errors created by merge.
JudithWell Feb 15, 2025
6151a48
removed unnecessary request argument
SirJonithan Feb 19, 2025
2ab59c1
Merge branch 'main' into main
SirJonithan Feb 19, 2025
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
21 changes: 10 additions & 11 deletions client/src/components/Administration/ProjectAdmin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const ProjectAdmin: React.FC = () => {

/* Helper method for fetching all projects of a course */
const getProjectsForCourse = (course: string): Promise<Project[]> => {
return get(`courseProject?projectGroupName=${course}`)
return get(`courseProject?courseName=${course}`)
.then(projects => projects.map((project: { id: string; projectName: string; studentsCanJoinProject: boolean; }) => ({
id: project.id,
projectName: project.projectName,
Expand All @@ -102,11 +102,11 @@ const ProjectAdmin: React.FC = () => {
const coursesData = await get("course");

const coursesWithProjects: Course[] = await Promise.all(
coursesData.map(async (course: { projectGroupName: string; semester: string; studentsCanCreateProject: boolean; }) => {
const projects = await getProjectsForCourse(course.projectGroupName);
coursesData.map(async (course: { courseName: string; semester: string; studentsCanCreateProject: boolean; }) => {
const projects = await getProjectsForCourse(course.courseName);
return {
semester: course.semester,
courseName: course.projectGroupName,
courseName: course.courseName,
projects: projects,
studentsCanCreateProject: course?.studentsCanCreateProject || false,
};
Expand All @@ -125,7 +125,7 @@ const ProjectAdmin: React.FC = () => {

/* Method for creating a course */
const handleCreateCourse = async (semester: string, courseName: string,) => {
const body: { [key: string]: string } = { semester, projectGroupName: courseName };
const body: { [key: string]: string } = { semester, courseName: courseName };

const data = await post("course", body).catch((error) => {
console.error("Error fetching data:", error.message);
Expand All @@ -142,7 +142,7 @@ const ProjectAdmin: React.FC = () => {
const handleCreateProject = async (projectName: string) => {
if (!selectedCourse) return;

const body: { [key: string]: string } = { semester: selectedCourse.semester, projectGroupName: selectedCourse.courseName, projectName };
const body: { [key: string]: string } = { semester: selectedCourse.semester, courseName: selectedCourse.courseName, projectName };

const data = await post("courseProject", body).catch((error) => {
console.error("Error fetching data:", error.message);
Expand All @@ -160,9 +160,8 @@ const ProjectAdmin: React.FC = () => {
if (!selectedCourse || !selectedProject) return;

const body: { [key: string]: string } = {
projectGroupName: selectedCourse.courseName,
newSemester: selectedCourse.semester,
newProjectGroupName: courseName,
courseName: selectedCourse.courseName,
newCourseName: courseName,
projectName: selectedProject.projectName,
newProjectName: projectName,
};
Expand All @@ -183,9 +182,9 @@ const ProjectAdmin: React.FC = () => {
if (!selectedCourse) return;

const body: { [key: string]: string | boolean } = {
projectGroupName: selectedCourse.courseName,
courseName: selectedCourse.courseName,
newSemester: editedCourse.semester,
newProjectGroupName: editedCourse.courseName,
newCourseName: editedCourse.courseName,
studentsCanCreateProject: editedCourse.studentsCanCreateProject,
};

Expand Down
10 changes: 5 additions & 5 deletions client/src/components/Administration/UserAdmin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function UserEdit({ user, onClose }: { user: User; onClose: (update: boolean) =>
{
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ "email": user.email.toString(), "newGithubUsername": githubUsername })
body: JSON.stringify({ "userEmail": user.email.toString(), "newGithubUsername": githubUsername })
})
.then(checkError)
.catch(console.error));
Expand All @@ -54,7 +54,7 @@ function UserEdit({ user, onClose }: { user: User; onClose: (update: boolean) =>
{
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ "email": user.email.toString(), "status": status })
body: JSON.stringify({ "userEmail": user.email.toString(), "status": status })
})
.then(checkError)
.catch(console.error));
Expand All @@ -64,7 +64,7 @@ function UserEdit({ user, onClose }: { user: User; onClose: (update: boolean) =>
{
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ "email": user.email.toString(), "password": password })
body: JSON.stringify({ "userEmail": user.email.toString(), "password": password })
})
.then(checkError)
.catch(console.error));
Expand Down Expand Up @@ -167,7 +167,7 @@ const UserAdmin = () => {
fetch(`/user/confirmation/trigger`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ email: user.email.toString() }),
body: JSON.stringify({ userEmail: user.email.toString() }),
})
.then(checkError)
.catch(console.error);
Expand Down Expand Up @@ -206,4 +206,4 @@ const UserAdmin = () => {
);
}

export default UserAdmin;
export default UserAdmin;
42 changes: 21 additions & 21 deletions client/src/components/Configuration/CourseParticipation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const CourseParticipation: React.FC = () => {
type Project = {
id: number;
projectName: string;
projectGroupName: string;
courseName: string;
};

const navigate = useNavigate();
Expand All @@ -43,14 +43,14 @@ const CourseParticipation: React.FC = () => {
email: string;
} | null>(null);

const [projectGroups, setProjectGroups] = useState<string[]>([]);
const [courses, setCourses] = useState<string[]>([]);
const [userProjects, setUserProjects] = useState<string[]>([]);

const [enrolledProjects, setEnrolledProjects] = useState<Project[]>([]);
const [selectedEnrolledProjectGroup, setSelectedEnrolledProjectGroup] = useState<string>("");
const [selectedEnrolledCourse, setSelectedEnrolledCourse] = useState<string>("");

const [availableProjects, setAvailableProjects] = useState<Project[]>([]);
const [selectedAvailableProjectGroup, setSelectedAvailableProjectGroup] = useState<string>("");
const [selectedAvailableCourse, setSelectedAvailableCourse] = useState<string>("");

useEffect(() => {
const fetchUserData = async () => {
Expand All @@ -68,11 +68,11 @@ const CourseParticipation: React.FC = () => {

fetchUserData();

const fetchProjectGroups = async () => {
const fetchCourses = async () => {
try {
const response = await fetch("http://localhost:3000/course");
const data = await response.json();
setProjectGroups(data.map((item: Project) => item.projectGroupName));
setCourses(data.map((item: Project) => item.courseName));
console.log("Fetched project groups:", data);
} catch (error: unknown) {
if (error instanceof Error) {
Expand All @@ -81,7 +81,7 @@ const CourseParticipation: React.FC = () => {
}
};

fetchProjectGroups();
fetchCourses();

const fetchUserProjects = async() => {
try {
Expand All @@ -102,16 +102,16 @@ const CourseParticipation: React.FC = () => {

useEffect(() => {
const fetchEnrolledProjects = async () => {
if (selectedEnrolledProjectGroup) {
if (selectedEnrolledCourse) {
try {
const response = await fetch(
`http://localhost:3000/courseProject?projectGroupName=${selectedEnrolledProjectGroup}`
`http://localhost:3000/courseProject?courseName=${selectedEnrolledCourse}`
);
const data = await response.json();
const mappedProjects = data.map((item: Project) => ({
id: item.id,
projectName: item.projectName,
projectGroupName: item.projectGroupName || selectedEnrolledProjectGroup,
courseName: item.courseName || selectedEnrolledCourse,
}));

const enrolledProjects = mappedProjects.filter((item: Project) => userProjects.includes(item.projectName));
Expand All @@ -128,24 +128,24 @@ const CourseParticipation: React.FC = () => {
};

fetchEnrolledProjects();
}, [selectedEnrolledProjectGroup]);
}, [selectedEnrolledCourse]);

const filteredEnrolledProjects = enrolledProjects.filter(
(project) => project.projectGroupName === selectedEnrolledProjectGroup
(project) => project.courseName === selectedEnrolledCourse
);

useEffect(() => {
const fetchAvailableProjects = async () => {
if (selectedAvailableProjectGroup) {
if (selectedAvailableCourse) {
try {
const response = await fetch(
`http://localhost:3000/courseProject?projectGroupName=${selectedAvailableProjectGroup}`
`http://localhost:3000/courseProject?courseName=${selectedAvailableCourse}`
);
const data = await response.json();
const mappedProjects = data.map((item: Project) => ({
id: item.id,
projectName: item.projectName,
projectGroupName: item.projectGroupName || selectedAvailableProjectGroup,
courseName: item.courseName || selectedAvailableCourse,
}));

const availableProjectsWithoutEnrolled = mappedProjects.filter((item: Project) => !userProjects.includes(item.projectName));
Expand All @@ -162,10 +162,10 @@ const CourseParticipation: React.FC = () => {
};

fetchAvailableProjects();
}, [selectedAvailableProjectGroup]);
}, [selectedAvailableCourse]);

const filteredAvailableProjects = availableProjects.filter(
(project: Project) => project.projectGroupName === selectedAvailableProjectGroup
(project: Project) => project.courseName === selectedAvailableCourse
);

const handleJoin = async (projectName: string) => {
Expand Down Expand Up @@ -263,14 +263,14 @@ const CourseParticipation: React.FC = () => {
<div className="SelectWrapper">
<Select
onValueChange={(value) => {
setSelectedEnrolledProjectGroup(value);
setSelectedEnrolledCourse(value);
}}
>
<SelectTrigger className="SelectTrigger">
<SelectValue placeholder="Select a project group" />
</SelectTrigger>
<SelectContent className="SelectContent">
{projectGroups.map((group, index) => (
{courses.map((group, index) => (
<SelectItem key={index} value={group}>
{group}
</SelectItem>
Expand Down Expand Up @@ -322,14 +322,14 @@ const CourseParticipation: React.FC = () => {
<div className="SelectWrapper">
<Select
onValueChange={(value) => {
setSelectedAvailableProjectGroup(value);
setSelectedAvailableCourse(value);
}}
>
<SelectTrigger className="SelectTrigger">
<SelectValue placeholder="Select a project group" />
</SelectTrigger>
<SelectContent className="SelectContent">
{projectGroups.map((group, index) => (
{courses.map((group, index) => (
<SelectItem key={index} value={group}>
{group}
</SelectItem>
Expand Down
10 changes: 5 additions & 5 deletions client/src/components/Configuration/ProjectConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const ProjectConfig: React.FC = () => {
`http://localhost:3000/user/courses?userEmail=${userEmail}`
);
const data = await response.json();
setCourses(data.map((course: { projectGroupName: string }) => course.projectGroupName));
setCourses(data.map((course: { courseName: string }) => course.courseName));
} catch (error) {
console.error("Error fetching courses:", error);
}
Expand Down Expand Up @@ -186,9 +186,9 @@ const ProjectConfig: React.FC = () => {
"Content-Type": "application/json",
},
body: JSON.stringify({
email: userEmail,
userEmail: userEmail,
URL: newURL,
project: selectedProject,
projectName: selectedProject,
}),
});
const data = await response.json();
Expand Down Expand Up @@ -290,7 +290,7 @@ const ProjectConfig: React.FC = () => {

const handleCreate = async (projectName: string) => {
const body = {
projectGroupName: selectedCourse,
courseName: selectedCourse,
projectName,
};

Expand Down Expand Up @@ -534,4 +534,4 @@ const ProjectConfig: React.FC = () => {
);
};

export default ProjectConfig;
export default ProjectConfig;
2 changes: 1 addition & 1 deletion client/src/components/Configuration/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ const Settings: React.FC = () => {
}

const body = {
email: user.email.toString(),
userEmail: user.email.toString(),
password: newPassword,
};

Expand Down
4 changes: 2 additions & 2 deletions client/src/components/Configuration/UserPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ const UserPanel: React.FC = () => {
}

const body = {
email: user.email.toString(),
userEmail: user.email.toString(),
password: newPassword,
};
try {
Expand Down Expand Up @@ -159,7 +159,7 @@ const UserPanel: React.FC = () => {
}

const body = {
email: user?.email,
userEmail: user?.email,
newGithubUsername: githubUsername,
};
let msg = document.getElementById('ErrorMessageGithub');
Expand Down
23 changes: 12 additions & 11 deletions client/src/components/Projects/CodeActivity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
owner: string;
repo: string;
} | null>(null);
const [sprints, setSprints] = useState<any[]>([]);

Check failure on line 41 in client/src/components/Projects/CodeActivity.tsx

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type

Check failure on line 41 in client/src/components/Projects/CodeActivity.tsx

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type

const [projectName, setProjectName] = useState<string | null>("");
const [user, setUser] = useState<{
Expand All @@ -46,8 +46,8 @@
email: string;
githubUsername: string;
} | null>(null);
const [selectedProjectGroup, setSelectedProjectGroup] = useState<string>("");
const [selectedCourse, setSelectedCourse] = useState<string>("");
const [commitsPerSprint, setCommitsPerSprint] = useState<any[]>([]);

Check failure on line 50 in client/src/components/Projects/CodeActivity.tsx

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type

Check failure on line 50 in client/src/components/Projects/CodeActivity.tsx

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type

const handleNavigation = () => {
navigate("/code-activity");
Expand All @@ -65,7 +65,7 @@
}, [location.state]);

useEffect(() => {
const fetchProjectGroup = async () => {
const fetchCourse = async () => {
if (!projectName) return;

try {
Expand All @@ -78,8 +78,8 @@
const text = await response.text();
if (text) {
const data = JSON.parse(text);
if (data && data.projectGroupName) {
setSelectedProjectGroup(data.projectGroupName);
if (data && data.courseName) {
setSelectedCourse(data.courseName);
}
} else {
console.error("Empty response body");
Expand All @@ -92,7 +92,7 @@
}
};

fetchProjectGroup();
fetchCourse();
}, [projectName]);

useEffect(() => {
Expand Down Expand Up @@ -129,7 +129,7 @@

try {
const response = await fetch(
`http://localhost:3000/user/user/projects?email=${encodeURIComponent(
`http://localhost:3000/user/projects?userEmail=${encodeURIComponent(
user.email.toString()
)}&projectName=${encodeURIComponent(projectName)}`
);
Expand Down Expand Up @@ -159,12 +159,12 @@

useEffect(() => {
const fetchAllSprints = async () => {
if (!selectedProjectGroup) return;

if (!selectedCourse) return;
try {
const response = await fetch(
`http://localhost:3000/sprints?projectGroupName=${encodeURIComponent(
selectedProjectGroup
`http://localhost:3000/sprints?courseName=${encodeURIComponent(
selectedCourse
)}`
);
const fetchedSprints: Sprint[] = await response.json();
Expand Down Expand Up @@ -193,7 +193,8 @@
};

fetchAllSprints();
}, [selectedProjectGroup]);
}, [selectedCourse]);


const getCommits = async (page: number) => {
if (!repoDetails || !sprints.length) {
Expand Down
Loading
Loading