Skip to content

Commit 2d05eaa

Browse files
committed
Merge branch 'ft-notify-new-travel-167730641' of https://github.com/andela/archangel-backend into ft-notify-new-travel-167730641
# Conflicts: # package.json # src/controllers/travelControllers.js # src/routes/travelRoute.js # src/services/travelServices.js # src/tests/travel.test.js # src/utils/messageUtils.js
2 parents 87e17e6 + 63b4184 commit 2d05eaa

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

src/routes/travelRoute.js

-2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,5 @@ route.patch(
6161
verifyDeptManagerAndRequestStatus,
6262
approveTravelRequest,
6363
);
64-
// Most travelled to destinations
65-
route.get('/most', getToken, verifyToken, mostTravelledDest);
6664

6765
export default route;

src/services/travelServices.js

+10-9
Original file line numberDiff line numberDiff line change
@@ -86,17 +86,18 @@ export const approveTravel = async (id) => {
8686
}
8787
};
8888

89-
export const mostTraveled = async () => {
89+
export const approveTravel = async (id) => {
9090
try {
91-
return await travel_requests.findAll({
92-
attributes: ['destination', [sequelize.fn('count', sequelize.col('destination')), 'count']],
93-
group: ['destination'],
94-
raw: true,
95-
order: sequelize.literal('count DESC'),
96-
limit: 3
91+
return await travel_requests.update({
92+
approval_status: 'accepted'
93+
}, {
94+
returning: true,
95+
where: {
96+
id
97+
}
9798
});
98-
} catch (error) {
99-
throw error;
99+
} catch (err) {
100+
throw err;
100101
}
101102
};
102103

0 commit comments

Comments
 (0)