Skip to content

Commit

Permalink
Bug/sort get session by user by new (#56)
Browse files Browse the repository at this point in the history
* test

* chore: clean up 2 lines

* fix: resolve conflicts

* chore: sort returned session list by newest first

when getting by userID
  • Loading branch information
Nfrederiksen authored Sep 30, 2021
1 parent 2c65c15 commit 5389954
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
HOST=localhost
PORT=8080
HOSTDOMAIN
HOSTDOMAIN
7 changes: 7 additions & 0 deletions controllers/memory-db-adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ class MemoryDBAdapter extends DBAdapter {
if (sessionList.length === 0) {
return null;
}
// Sort by newest first
sessionList.sort((a, b) => {
const dateA = new Date(a["created"]);
const dateB = new Date(b["created"]);
return dateB - dateA;
});

return sessionList;
}

Expand Down

0 comments on commit 5389954

Please sign in to comment.