Movie last update time #2

Merged
quoije merged 2 commits from cursor/movie-last-update-time-6461 into 2026 2025-12-20 16:32:22 -05:00
2 changed files with 28 additions and 1 deletions
Showing only changes of commit 0d35a19cc5 - Show all commits
+1 -1
View File
@@ -98,7 +98,7 @@
<!-- Displaying last updated vod_links --> <!-- Displaying last updated vod_links -->
<div class="alert alert-warning fade show" role="alert"> <div class="alert alert-warning fade show" role="alert">
Dernière mise à jour des films: <strong>—</strong> Dernière mise à jour des films: <strong id="movies-last-updated">—</strong>
</div> </div>
cursor[bot] commented 2025-12-20 16:34:48 -05:00 (Migrated from github.com)
Review

Missing frontend code to display last update timestamp

The #movies-last-updated HTML element is added and the /last-update API endpoint is implemented, but there's no JavaScript code in app_movies.js to fetch from the endpoint and update the DOM element. Users will always see "—" instead of the actual last update timestamp, making this feature non-functional.

Additional Locations (1)

Fix in Cursor Fix in Web

### Missing frontend code to display last update timestamp <!-- **Medium Severity** --> <!-- DESCRIPTION START --> The `#movies-last-updated` HTML element is added and the `/last-update` API endpoint is implemented, but there's no JavaScript code in `app_movies.js` to fetch from the endpoint and update the DOM element. Users will always see "—" instead of the actual last update timestamp, making this feature non-functional. <!-- DESCRIPTION END --> <!-- LOCATIONS START public/movies.html#L100-L101 routes/movies.js#L41-L66 LOCATIONS END --> <details> <summary>Additional Locations (1)</summary> - [`routes/movies.js#L41-L66`](https://github.com/quoije/oscars-pool/blob/0d35a19cc51cb7943d1e0bd2c35cb65125e93f8e/routes/movies.js#L41-L66) </details> <a href="https://cursor.com/open?data=eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImJ1Z2JvdC12MiJ9.eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9DVVJTT1IiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OmFiZTZjYjNjLTM2NmItNGY5NC04OGU5LTllMThkODU0NDQ3ZCIsImVuY3J5cHRpb25LZXkiOiJEclRja1ZiSVc5a2lETjhZN2JkNC1HWWlhZGU0Z0I1S2RYNHVOTk9yUmdNIiwiYnJhbmNoIjoiY3Vyc29yL21vdmllLWxhc3QtdXBkYXRlLXRpbWUtNjQ2MSJ9LCJpYXQiOjE3NjYyNjY0ODgsImV4cCI6MTc2ODg1ODQ4OH0.VCigOSl0VVsRlJ3PuJABowRj5EzfGOw3Gixr3gbQEulSDn0rNFIkXMzflyZgiDERnvNfK8txCNbpaUq471JAzZT7LS3dof8ZfsYqWxkROy4-gyydtqXiz5hpFLPhi9WMu6aanIVavxPHuF_-wtwxjVn_PKALIvqQgd9yumH3ZN5IpYx8o7F0IsO_kWWQoBh5Mr8uF1x6lD9u_duPzobyIGyyUXUeqSqBr1y9G_4-DWjhgS1t5HLZlubuduvJpKBQBlTufiIAVmYWQsHq1KwnUAFvirGHUmP1FEJkLG7eSKZp61l5GGmd1G8Dg-VheHYLpWut3-E1tW2m3sdDfgCbQw" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/fix-in-cursor-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/fix-in-cursor-light.svg"><img alt="Fix in Cursor" src="https://cursor.com/fix-in-cursor.svg"></picture></a>&nbsp;<a href="https://cursor.com/agents?data=eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImJ1Z2JvdC12MiJ9.eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9XRUIiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OmFiZTZjYjNjLTM2NmItNGY5NC04OGU5LTllMThkODU0NDQ3ZCIsImVuY3J5cHRpb25LZXkiOiJEclRja1ZiSVc5a2lETjhZN2JkNC1HWWlhZGU0Z0I1S2RYNHVOTk9yUmdNIiwiYnJhbmNoIjoiY3Vyc29yL21vdmllLWxhc3QtdXBkYXRlLXRpbWUtNjQ2MSIsInJlcG9Pd25lciI6InF1b2lqZSIsInJlcG9OYW1lIjoib3NjYXJzLXBvb2wiLCJwck51bWJlciI6MiwiY29tbWl0U2hhIjoiMGQzNWExOWNjNTFjYjc5NDNkMWUwYmQyYzM1Y2I2NTEyNWU5M2Y4ZSIsInByb3ZpZGVyIjoiZ2l0aHViIn0sImlhdCI6MTc2NjI2NjQ4OCwiZXhwIjoxNzY4ODU4NDg4fQ.Qr4tU8ozI1z0CKvXHKWwXs-MmIZ_3bxnF75aJSEkrsqLoIFy2jgJJh2Z11JZsI76r2qQBO31-YAvmDWhiMOQuJtOFwouJ41tGD1k8giY2tYzPcvGzxP-HtwMS3gwKcs6VFPT3f2_d7TaZeqJNT5ozVaGHNtyZRJoK4Jo9upigBMj1E4xJqv-1jguuyjUbCiRtqe_wvBjf0BTGE_nXuDKKdIWcPhcLyY1tCpeBLvnZw2C08dXZpeqBMlrGpPAB76yfiqoHfZvQoW4DozsDEudkzo3ahSoN_CiBLVApUXATp-pNLGU8Lz8wLWmC9Bei33NvDhayTciQYX5ESbKxBku6w" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/fix-in-web-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/fix-in-web-light.svg"><img alt="Fix in Web" src="https://cursor.com/fix-in-web.svg"></picture></a>
<!-- Displaying the ratio of watched movies --> <!-- Displaying the ratio of watched movies -->
+27
View File
@@ -38,6 +38,33 @@ router.get("/", async (req, res) => {
} }
}); });
// Get latest movie update/add timestamp
router.get("/last-update", async (req, res) => {
const token = req.headers.authorization?.split(" ")[1];
if (!token) return res.status(401).json({ message: "Token is required" });
try {
jwt.verify(token, process.env.JWT_SECRET);
const latestMovie = await Movie.findOne().sort({ updatedAt: -1, createdAt: -1, _id: -1 });
if (!latestMovie) {
return res.status(200).json({ lastUpdated: null });
}
const lastUpdated =
latestMovie.updatedAt ||
latestMovie.createdAt ||
(typeof latestMovie._id?.getTimestamp === "function" ? latestMovie._id.getTimestamp() : null);
return res.status(200).json({ lastUpdated: lastUpdated ? new Date(lastUpdated).toISOString() : null });
} catch (error) {
if (error instanceof jwt.JsonWebTokenError) {
return res.status(401).json({ message: "Invalid or expired token" });
}
return res.status(500).json({ error: error.message });
}
});
// Get watched movies for the user // Get watched movies for the user
router.get("/watchedMovies", async (req, res) => { router.get("/watchedMovies", async (req, res) => {
const token = req.headers.authorization?.split(" ")[1]; // Get token from header const token = req.headers.authorization?.split(" ")[1]; // Get token from header