Skip to content
This repository has been archived by the owner on Jul 1, 2024. It is now read-only.

Commit

Permalink
feat: admin list new profiles (#9960)
Browse files Browse the repository at this point in the history
  • Loading branch information
eddiejaoude committed Dec 19, 2023
1 parent 13e133b commit a7fa8f5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions pages/admin/profiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export default function Users({ profiles }) {
<Button href="/admin/profiles?filter=recently updated">
Recently updated
</Button>
<Button href="/admin/profiles?filter=new">New</Button>
<Button href="/admin/profiles?filter=by rank">By Rank</Button>
<Button href="/admin/profiles?filter=premium">Premium</Button>
<Button href="/admin/profiles?filter=isDisabled">Disabled</Button>
Expand Down
11 changes: 11 additions & 0 deletions pages/api/admin/profiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,16 @@ export async function getProfiles(filter = "recently updated", limit = 100) {
}
}

if (filter === "new") {
try {
profiles = await Profile.find({ isEnabled: true, views: { $lt: 20 } })
.sort({ updatedAt: -1 })
.limit(limit);
} catch (e) {
logger.error(e, "failed loading profiles");
return profiles;
}
}

return JSON.parse(JSON.stringify(profiles));
}

0 comments on commit a7fa8f5

Please sign in to comment.