Daily watch time changes

This commit is contained in:
Sanidhya Singh
2025-05-05 22:56:18 +05:30
parent f05d9fb948
commit c1800334a6
5 changed files with 41 additions and 23 deletions

View File

@@ -423,6 +423,7 @@ router.get("/getViewsOverTime", async (req, res) => {
stats.forEach((item) => {
const library = item.Library;
const count = item.Count;
const watchTime = item.TotalTime;
const date = new Date(item.Date).toLocaleDateString("en-US", {
year: "numeric",
month: "short",
@@ -435,7 +436,7 @@ router.get("/getViewsOverTime", async (req, res) => {
};
}
reorganizedData[date] = { ...reorganizedData[date], [library]: count };
reorganizedData[date] = { ...reorganizedData[date], [library]: { count, watchTime } };
});
const finalData = { libraries: libraries, stats: Object.values(reorganizedData) };
res.send(finalData);