Skip to content

Commit d728fdf

Browse files
committed
Add condition for all launches to check order of launches before concat
1 parent 41c7dc9 commit d728fdf

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/controllers/launches.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ module.exports = {
3838
* Return all past and upcoming launches
3939
*/
4040
all: async (ctx) => {
41+
let data;
4142
const past = await global.db
4243
.collection('launch_v2')
4344
.find(launchQuery(ctx.request))
@@ -52,7 +53,11 @@ module.exports = {
5253
.sort(sortQuery(ctx.request))
5354
.limit(limitQuery(ctx.request))
5455
.toArray();
55-
const data = past.concat(upcoming);
56+
if (past[past.length - 1].flight_number === 1) {
57+
data = upcoming.concat(past);
58+
} else {
59+
data = past.concat(upcoming);
60+
}
5661
ctx.body = data;
5762
},
5863

0 commit comments

Comments
 (0)