diff --git a/.gitignore b/.gitignore index 313b735..05f913b 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ bin database.txt plantuml.jar db.sqlite3 +db.sqlite3-journal diagram.puml backend/*.png backend/*.jpg diff --git a/backend/internal/database/migrations/0035_weekly_report.sql b/backend/internal/database/migrations/0035_weekly_report.sql index 8f76b80..be2a2d3 100644 --- a/backend/internal/database/migrations/0035_weekly_report.sql +++ b/backend/internal/database/migrations/0035_weekly_report.sql @@ -1,5 +1,5 @@ CREATE TABLE IF NOT EXISTS weekly_reports ( - report_id INTEGER PRIMARY KEY AUTOINCREMENT, + report_id INTEGER AUTO_INCREMENT UNIQUE, user_id INTEGER NOT NULL, project_id INTEGER NOT NULL, week INTEGER NOT NULL, @@ -12,5 +12,6 @@ CREATE TABLE IF NOT EXISTS weekly_reports ( signed_by INTEGER, FOREIGN KEY (user_id) REFERENCES users(id), FOREIGN KEY (project_id) REFERENCES projects(id), - FOREIGN KEY (signed_by) REFERENCES users(id) + FOREIGN KEY (signed_by) REFERENCES users(id), + PRIMARY KEY (user_id, project_id, week) ); \ No newline at end of file diff --git a/backend/internal/database/sample_data/0010_sample_data.sql b/backend/internal/database/sample_data/0010_sample_data.sql index 4dac91b..092fbb0 100644 --- a/backend/internal/database/sample_data/0010_sample_data.sql +++ b/backend/internal/database/sample_data/0010_sample_data.sql @@ -33,3 +33,18 @@ VALUES (3,3,"member"); INSERT OR IGNORE INTO user_roles(user_id,project_id,p_role) VALUES (2,1,"project_manager"); + +INSERT OR IGNORE INTO weekly_reports (user_id, project_id, week, development_time, meeting_time, admin_time, own_work_time, study_time, testing_time, signed_by) +VALUES (2, 1, 12, 20, 10, 5, 30, 15, 10, NULL); + +INSERT OR IGNORE INTO weekly_reports (user_id, project_id, week, development_time, meeting_time, admin_time, own_work_time, study_time, testing_time, signed_by) +VALUES (3, 1, 12, 20, 10, 5, 30, 15, 10, NULL); + +INSERT OR IGNORE INTO weekly_reports (user_id, project_id, week, development_time, meeting_time, admin_time, own_work_time, study_time, testing_time, signed_by) +VALUES (3, 1, 14, 20, 10, 5, 30, 15, 10, NULL); + +INSERT OR IGNORE INTO weekly_reports (user_id, project_id, week, development_time, meeting_time, admin_time, own_work_time, study_time, testing_time, signed_by) +VALUES (3, 2, 12, 20, 10, 5, 30, 15, 10, NULL); + +INSERT OR IGNORE INTO weekly_reports (user_id, project_id, week, development_time, meeting_time, admin_time, own_work_time, study_time, testing_time, signed_by) +VALUES (3, 3, 12, 20, 10, 5, 30, 15, 10, NULL); diff --git a/frontend/src/API/API.ts b/frontend/src/API/API.ts index 47299f3..0859748 100644 --- a/frontend/src/API/API.ts +++ b/frontend/src/API/API.ts @@ -87,14 +87,12 @@ interface API { ): Promise>; /** Gets a weekly report for a specific user, project and week - * @param {string} username The username of the user. * @param {string} projectName The name of the project. * @param {string} week The week number. * @param {string} token The authentication token. * @returns {Promise>} A promise resolving to an API response with the retrieved report. */ getWeeklyReport( - username: string, projectName: string, week: string, token: string, @@ -319,20 +317,21 @@ export const api: API = { }, async getWeeklyReport( - username: string, projectName: string, week: string, token: string, ): Promise> { try { - const response = await fetch("/api/getWeeklyReport", { - method: "GET", - headers: { - "Content-Type": "application/json", - Authorization: "Bearer " + token, + const response = await fetch( + `/api/getWeeklyReport?projectName=${projectName}&week=${week}`, + { + method: "GET", + headers: { + "Content-Type": "application/json", + Authorization: "Bearer " + token, + }, }, - body: JSON.stringify({ username, projectName, week }), - }); + ); if (!response.ok) { return { success: false, message: "Failed to get weekly report" }; diff --git a/frontend/src/Components/AllTimeReportsInProject.tsx b/frontend/src/Components/AllTimeReportsInProject.tsx index 614019c..fcd0f8f 100644 --- a/frontend/src/Components/AllTimeReportsInProject.tsx +++ b/frontend/src/Components/AllTimeReportsInProject.tsx @@ -16,8 +16,8 @@ function AllTimeReportsInProject(): JSX.Element { const getWeeklyReports = async (): Promise => { const token = localStorage.getItem("accessToken") ?? ""; const response = await api.getWeeklyReportsForUser( - token, projectName ?? "", + token, ); console.log(response); if (response.success) {