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

test cases for activity feed backend #1976

Merged
merged 17 commits into from
Mar 21, 2024
Merged
Changes from 1 commit
Commits
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
issue-700-backend: refactoring of the code
  • Loading branch information
palakgupta2712 committed Mar 18, 2024
commit e0f8d557bde57dd8934c22abce1422a181d568c0
40 changes: 14 additions & 26 deletions utils/logs.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,33 +47,21 @@ function formatRequestCreatedLogs(logsSnapshot, usersMap) {
}
}
function formatExtensionRequestsLog(logsSnapshot, usersMap) {
switch (logsSnapshot.body.status) {
case EXTENSION_REQUEST_STATUS.PENDING:
return {
user: logsSnapshot.meta.username ?? usersMap[logsSnapshot.meta.assignee]?.username,
taskId: logsSnapshot.meta.taskId,
newEndsOn: logsSnapshot.body.newEndsOn,
oldEndsOn: logsSnapshot.body.oldEndsOn,
extensionRequestId: logsSnapshot.body.extensionRequestId,
status: logsSnapshot.body.status,
};
case EXTENSION_REQUEST_STATUS.APPROVED:
return {
user: logsSnapshot.meta.username ?? usersMap[logsSnapshot.meta.userId]?.username,
taskId: logsSnapshot.meta.taskId,
extensionRequestId: logsSnapshot.body.extensionRequestId,
status: logsSnapshot.body.status,
};
case EXTENSION_REQUEST_STATUS.DENIED:
return {
user: logsSnapshot.meta.username ?? usersMap[logsSnapshot.meta.userId]?.username,
taskId: logsSnapshot.meta.taskId,
extensionRequestId: logsSnapshot.body.extensionRequestId,
status: logsSnapshot.body.status,
};
default:
return {};
const { meta, body } = logsSnapshot;
const formattedLog = {
user: logsSnapshot.meta.username ?? usersMap[logsSnapshot.meta.userId]?.username,
taskId: meta.taskId,
extensionRequestId: body.extensionRequestId,
status: body.status,
};

if (body.status === EXTENSION_REQUEST_STATUS.PENDING) {
formattedLog.user = logsSnapshot.meta.username ?? usersMap[logsSnapshot.meta.assignee]?.username;
formattedLog.newEndsOn = body.newEndsOn;
formattedLog.oldEndsOn = body.oldEndsOn;
}

return formattedLog;
}

function formatTaskUpdateLogs(logsSnapshot, usersMap) {
Expand Down
Loading