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

Release for Iteration 3 #104

Closed
wants to merge 89 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
0cbf6b8
Manage Goal Functionality
ZihaoQian Oct 7, 2024
285d896
ValidateGoalForm TEST
ZihaoQian Oct 7, 2024
2f5bfd8
Logout Test
ZihaoQian Oct 8, 2024
541d215
Login test
ZihaoQian Oct 8, 2024
8baa9fa
remove old goal and progress schema that are not used
amanda-yee Oct 8, 2024
76e9c2e
Added my progress report for this sprint
kenlight-bu Oct 8, 2024
177d148
Pull in changes from main
eddie27lee Oct 9, 2024
942c65d
Keep database reset code
eddie27lee Oct 9, 2024
0c9b098
Update apiClient.js
eddie27lee Oct 9, 2024
6eeea94
Keep database reset code
eddie27lee Oct 9, 2024
81e5ba8
Merge pull request #81 from BUMETCS673/dev-sync
amanda-yee Oct 9, 2024
98f47de
organize charts as two per row
amanda-yee Oct 9, 2024
bb38dce
Merge pull request #77 from BUMETCS673/remove_deprecated_schemas
eddie27lee Oct 10, 2024
20c450e
apply white background to charts and center
amanda-yee Oct 10, 2024
cdde067
print welcome with personalized name
amanda-yee Oct 10, 2024
2609fab
add icons
amanda-yee Oct 10, 2024
5ce5f35
revert sidebar width
amanda-yee Oct 10, 2024
941e79b
revert chart width
amanda-yee Oct 10, 2024
e0ac0b8
remove comment
amanda-yee Oct 10, 2024
c2673c1
update chart titles
amanda-yee Oct 10, 2024
2fbdc1e
Merge pull request #82 from BUMETCS673/hw190_homepage_ui_name
ccerav-bu Oct 10, 2024
20f0c76
updated topBar and sideBar, change gird to grid2
abbiekuma Oct 11, 2024
f59c226
Merge pull request #83 from BUMETCS673/UIupdate2
amanda-yee Oct 11, 2024
3630294
clean up readme
amanda-yee Oct 11, 2024
241e1e0
update heading levels
amanda-yee Oct 11, 2024
e58ddc9
update heading levels again
amanda-yee Oct 11, 2024
b94254e
make the side bar wider
abbiekuma Oct 11, 2024
5479c7b
remove learn more section in client readme
amanda-yee Oct 11, 2024
040c2fb
chart size changed
abbiekuma Oct 11, 2024
f991514
Merge pull request #84 from BUMETCS673/sideBar
amanda-yee Oct 11, 2024
a274e71
Merge pull request #85 from BUMETCS673/update_readme
eddie27lee Oct 11, 2024
cd8f07a
changed styling and refactored chart generation code
ccerav-bu Oct 12, 2024
39a3dbd
Login Test
ZihaoQian Oct 12, 2024
68a32d6
Merge pull request #86 from BUMETCS673/Hw-175-logout
kenlight-bu Oct 12, 2024
6c78e26
add additional form validations
amanda-yee Oct 12, 2024
419192c
Added zxcvbn to check password strength. Added password meter. Disab…
kenlight-bu Oct 12, 2024
ac97e47
add tests for goal form
amanda-yee Oct 12, 2024
c2585d4
daily data tests
amanda-yee Oct 12, 2024
9794a93
clean up wording
amanda-yee Oct 12, 2024
145520b
fixing some UTC issues with daily date process
ccerav-bu Oct 12, 2024
1a74470
remove duplicate code
amanda-yee Oct 12, 2024
5efce93
Merge pull request #89 from BUMETCS673/daily_data_utc_fix
amanda-yee Oct 12, 2024
423a6e2
Changed the password strength to level 2
kenlight-bu Oct 12, 2024
c8e9cbe
I added different password strength -
kenlight-bu Oct 12, 2024
9c9206c
Merge pull request #90 from BUMETCS673/cleanup_styles_file
kenlight-bu Oct 12, 2024
4ae20ce
Merge remote-tracking branch 'origin/dev' into HW-181
kenlight-bu Oct 12, 2024
a8c9568
Not sure why but confirmPassword sx name changed. Changed it back th…
kenlight-bu Oct 12, 2024
5b2bb04
GoalController Test
ZihaoQian Oct 12, 2024
6e19236
Merge pull request #91 from BUMETCS673/HW-181
amanda-yee Oct 12, 2024
04625f2
Merge branch 'dev' into Hw-180-EditGoal
ZihaoQian Oct 12, 2024
5ce5680
Goal data visible in FrontEnd
ZihaoQian Oct 12, 2024
50cffd5
Update goalController.test.js
ZihaoQian Oct 12, 2024
bbfe6c4
Merge pull request #93 from BUMETCS673/Hw-180-EditGoal
kenlight-bu Oct 12, 2024
b146197
some progress
ccerav-bu Oct 12, 2024
588dfa5
progress
ccerav-bu Oct 12, 2024
e02cd48
Merge remote-tracking branch 'origin/dev' into HW_183_Real_Data
ccerav-bu Oct 12, 2024
7133d87
Connected charts to data
ccerav-bu Oct 13, 2024
a4b325a
merge dev
amanda-yee Oct 13, 2024
83c32ec
update tests based on new dev
amanda-yee Oct 13, 2024
a40f91f
validating messages print out
amanda-yee Oct 13, 2024
e781538
remove whitespace
amanda-yee Oct 13, 2024
fe11fc4
Added test
ccerav-bu Oct 14, 2024
0f812cc
Merge pull request #87 from BUMETCS673/hw191_update_validation_limits
ccerav-bu Oct 14, 2024
d65f1d1
commented out deletions in initdb_userDailyData
ccerav-bu Oct 14, 2024
77161cf
Merge pull request #94 from BUMETCS673/HW_183_Real_Data
amanda-yee Oct 14, 2024
9ec391b
remove commented out code
amanda-yee Oct 14, 2024
00df6fd
Merge pull request #95 from BUMETCS673/cleanup_repo
eddie27lee Oct 14, 2024
022f5ed
Store jwt in cookie instead of local storage
eddie27lee Oct 14, 2024
ec73036
Merge branch 'dev' into elee/hw-188
eddie27lee Oct 14, 2024
7de818f
Remove unused import
eddie27lee Oct 14, 2024
5471583
Readd setting userId after login
eddie27lee Oct 14, 2024
83cce15
Change var back to authToken from token
eddie27lee Oct 14, 2024
773226e
Change test cases to not use res
eddie27lee Oct 14, 2024
b9b5e77
Missed res fix
eddie27lee Oct 14, 2024
a17e6f0
Use toBeNil instead of null to check for undefined
eddie27lee Oct 14, 2024
af5d7cd
install jest-extended
eddie27lee Oct 14, 2024
2a54781
Change to expect undefined
eddie27lee Oct 14, 2024
a5a2c4d
Remove from deploy.yml
eddie27lee Oct 14, 2024
0d47f9f
Update Logout.test.js comment
eddie27lee Oct 14, 2024
03e00a9
Merge pull request #96 from BUMETCS673/elee/hw-188
ccerav-bu Oct 14, 2024
3b4b76b
Test cases for dailyEntryController
eddie27lee Oct 14, 2024
6e6ae17
Merge pull request #97 from BUMETCS673/elee/dailyEntryTests
amanda-yee Oct 14, 2024
5c22b06
Pull in dependabot updates to dev
eddie27lee Oct 15, 2024
a84e4df
Deploy current branch
eddie27lee Oct 15, 2024
3af756b
Reset deploy.yml
eddie27lee Oct 15, 2024
9e675b2
Merge pull request #99 from BUMETCS673/elee-security
eddie27lee Oct 15, 2024
fd07ba5
remove unused imports
amanda-yee Oct 15, 2024
ee97248
Merge pull request #100 from BUMETCS673/fix_warnings
amanda-yee Oct 15, 2024
c5eecdb
Release for Iteration 3
eddie27lee Oct 15, 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
Prev Previous commit
Next Next commit
progress
  • Loading branch information
ccerav-bu committed Oct 12, 2024
commit 588dfa5e67de1808223443fde23dcfd1aec4cf14
63 changes: 63 additions & 0 deletions code/server/controllers/dailyEntryController.js
Original file line number Diff line number Diff line change
@@ -163,4 +163,67 @@ exports.deleteEntry = async (req, res) => {
} catch (error) {
res.status(500).json({ message: 'Error deleting daily entry' });
}
};

exports.lastSevenDays = async (req, res) => {
try {
// Get token from Authorization header
const authHeader = req.headers['authorization'];
if (!authHeader) {
return res.status(401).json({ message: 'Authorization header is missing' });
}
const token = authHeader.split(' ')[1];
if (!token) {
return res.status(401).json({ message: 'Token is missing' });
}

// Verify and decode the token
const secretKey = process.env.SECRET_KEY;
const decoded = jwt.verify(token, secretKey);

// Extract userId from the decoded token
const userId = decoded.userId;

// Initialize the array for the last seven days of data
const lastSevenDaysData = [];

// Get the current date in UTC
const today = new Date();

// Loop over the last seven days
for (let i = 0; i < 7; i++) {
// Calculate the date for i days ago in UTC
const date = new Date(today);
date.setUTCDate(today.getUTCDate() - i); // Subtract i days

// Define the start and end of the day in UTC
const startOfDay = new Date(Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), 0, 0, 0, 0));
const endOfDay = new Date(Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), 23, 59, 59, 999));

// Create a query to find the entry for the current day and user, based on UTC time
const entry = await DailyEntry.findOne({
userId: userId,
entryDate: {
$gte: startOfDay, // Start of the day in UTC
$lt: endOfDay // End of the day in UTC
}
});

// If an entry exists, push it to the array, otherwise push null
if (entry) {
lastSevenDaysData.push(entry);
} else {
lastSevenDaysData.push(null);
}
}

// Send the array of data to the client
return res.status(200).json({
data: lastSevenDaysData
});

} catch (error) {
console.error(error);
res.status(500).json({ message: 'Error getting last seven days of data' });
}
};