Skip to content

Commit

Permalink
Merge pull request #138 from sparcs-kaist/feat/sort_by_time
Browse files Browse the repository at this point in the history
  • Loading branch information
withSang authored Oct 25, 2023
2 parents 94bb7d1 + db17670 commit 78ffe93
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/controllers/zabo.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,16 +182,18 @@ export const deleteZabo = ash(async (req, res) => {
return res.send(true);
});

const queryZabos = async (req, queryOptions) => {
const queryZabos = async (req, queryOptions, sortBy = "createdAt") => {
const sortOption = {};
sortOption[sortBy] = -1;
const zabos = await Zabo.find(queryOptions)
.sort({ score: -1 })
.sort(sortOption)
.limit(20)
.populate("owner", "name profilePhoto subtitle description");
return populateZabosPrivateStats(zabos, req.self);
};

export const listHotZabos = ash(async (req, res) => {
const zabos = await queryZabos(req, {}); // TODO: Store likes count with pre
const zabos = await queryZabos(req, {}, "score"); // TODO: Store likes count with pre
// save
// or some other hooks
const results = [];
Expand Down

0 comments on commit 78ffe93

Please sign in to comment.