feat: Show last updated movies per year
Add API and UI to display the last updated movies for the active year. Co-authored-by: mathieumoran1 <[email protected]>
This commit is contained in:
co-authored by
mathieumoran1
parent
03a4b4e5dc
commit
6cb503fe35
+4
-1
@@ -73,7 +73,10 @@ router.get("/last-update", async (req, res) => {
|
||||
try {
|
||||
jwt.verify(token, process.env.JWT_SECRET);
|
||||
|
||||
const latestMovie = await Movie.findOne().sort({ updatedAt: -1, createdAt: -1, _id: -1 });
|
||||
const year = parseOscarYear(req.query.year);
|
||||
const filter = year ? { year } : {};
|
||||
|
||||
const latestMovie = await Movie.findOne(filter).sort({ updatedAt: -1, createdAt: -1, _id: -1 });
|
||||
if (!latestMovie) {
|
||||
return res.status(200).json({ lastUpdated: null });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user