Skip to content

Commit b293364

Browse files
committed
refactor
1 parent 78f6cb5 commit b293364

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

server/db/index.js

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,14 @@ const getMaxSeats = restaurantId => restaurant.getMaxSeats(restaurantId);
1212
const getOpenSeats = ({
1313
restaurantId, date,
1414
}) => restaurant.getBookingsForDate(restaurantId, date)
15-
.then((res) => {
16-
const seatsBookedAtTime = res.reduce((acc, curr) => {
17-
if (acc[curr.time]) {
18-
acc[curr.time] += curr.party;
19-
} else {
20-
acc[curr.time] = curr.party;
21-
}
22-
return acc;
23-
}, {});
24-
return seatsBookedAtTime;
25-
})
15+
.then(res => res.reduce((acc, curr) => {
16+
if (acc[curr.time]) {
17+
acc[curr.time] += curr.party;
18+
} else {
19+
acc[curr.time] = curr.party;
20+
}
21+
return acc;
22+
}, {}))
2623
.then(seatsBooked => (
2724
getMaxSeats(restaurantId).then(res => (
2825
Object.entries(seatsBooked).map(i => ({

0 commit comments

Comments
 (0)