Skip to content
Merged
Show file tree
Hide file tree
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
refactor: Refactor of code smells
  • Loading branch information
cxcarvaj committed Feb 16, 2022
commit 55a06c274eb061cd6b3ac0a4e593dfceafbfddb1
18 changes: 6 additions & 12 deletions nodejs-functions/src/handlers/automatic-clock-outs/clock_out.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ const SlackClient = require('./slack_client');
const { CLOCK_OUT_MESSAGE, CLOCK_OUT_MESSAGE_MIDNIGHT } = require('./constants');

const doClockOut = async (context) => {
context.log(
`I am going to check how many entries were not clocked out ${new Date()}`
);
context.log(`I am going to check how many entries were not clocked out ${new Date()}`);

const { endpoint, key, databaseId } = config;
const client = new CosmosClient({ endpoint, key });
Expand Down Expand Up @@ -52,21 +50,17 @@ const doClockOut = async (context) => {
})
);

context.log(
`I just clocked out ${totalClockOutsExecuted} entries, thanks are not needed...`
);
context.log(`I just clocked out ${totalClockOutsExecuted} entries, thanks are not needed...`);
};

const findUserData = (users, id) => {
const user = users.find((user) => user.id === id);
return user
? { userName: user.name.split(' ')[0], userEmail: user.email }
: {};
const targetUser = users.find((user) => user.id === id);
return targetUser ? { userName: targetUser.name.split(' ')[0], userEmail: targetUser.email } : {};
};

const findSlackUserId = (slackUsers, email) => {
const user = slackUsers.find((slackUser) => slackUser.email === email);
return user ? user.id : null;
const slackTargetUser = slackUsers.find((slackUser) => slackUser.email === email);
return slackTargetUser ? slackTargetUser.id : null;
};

module.exports = { doClockOut };
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ const getToken = async () => {
},
};

return await axios
.post(endpoint, params, headers)
return axios.post(endpoint, params, headers)
.then((result) => {
return result.data.access_token;
})
Expand All @@ -41,7 +40,7 @@ const findUsersInMS = async () => {
},
};

return await axios.get(`${endpoint}/users`, headers);
return axios.get(`${endpoint}/users`, headers);
};

module.exports = { findUsersInMS };