Browse Source

Fix See Later artefacts

pull/11/head
astria 3 months ago
parent
commit
298d49aecb
  1. 47
      backend/app/controllers/playlist.controller.js
  2. 23
      backend/logs/access.log

47
backend/app/controllers/playlist.controller.js

@ -238,26 +238,29 @@ export async function getSeeLater(req, res) {
const client = await getClient(); const client = await getClient();
const query = ` const query = `
SELECT SELECT
JSON_AGG( COALESCE(
json_build_object( JSON_AGG(
'video_id', videos.id, json_build_object(
'title', videos.title, 'video_id', videos.id,
'thumbnail', videos.thumbnail, 'title', videos.title,
'video_decscription', videos.description, 'thumbnail', videos.thumbnail,
'channel', videos.channel, 'video_decscription', videos.description,
'visibility', videos.visibility, 'channel', videos.channel,
'file', videos.file, 'visibility', videos.visibility,
'format', videos.format, 'file', videos.file,
'release_date', videos.release_date, 'format', videos.format,
'channel_id', channels.id, 'release_date', videos.release_date,
'owner', channels.owner, 'channel_id', channels.id,
'views', COALESCE(video_views.view_count, 0), 'owner', channels.owner,
'creator', json_build_object( 'views', COALESCE(video_views.view_count, 0),
'name', channels.name, 'creator', json_build_object(
'profilePicture', users.picture, 'name', channels.name,
'description', channels.description 'profilePicture', users.picture,
'description', channels.description
)
) )
) ) FILTER (WHERE videos.id IS NOT NULL),
'[]'::json
) AS videos ) AS videos
FROM FROM
public.playlists public.playlists
@ -285,14 +288,14 @@ export async function getSeeLater(req, res) {
try { try {
const result = await client.query(query, [userId]); const result = await client.query(query, [userId]);
if (result.rows.length === 0) { if (result.rows.length === 0) {
logger.write("No 'See Later' playlist found for user with id " + userId, 404); logger.write("No 'See Later' playlist found for user with id " + userId, 200);
client.release(); client.release();
res.status(404).json({ error: "'See Later' playlist not found" }); res.status(200).json([]);
return; return;
} }
logger.write("'See Later' playlist retrieved for user with id " + userId, 200); logger.write("'See Later' playlist retrieved for user with id " + userId, 200);
client.release(); client.release();
res.status(200).json(result.rows[0].videos); res.status(200).json(result.rows[0].videos || []);
} catch (error) { } catch (error) {
logger.write("Error retrieving 'See Later' playlist: " + error.message, 500); logger.write("Error retrieving 'See Later' playlist: " + error.message, 500);
client.release(); client.release();

23
backend/logs/access.log

@ -11461,3 +11461,26 @@
[2025-08-31 10:29:58.869] [undefined] GET(/:id/stats): try to get stats [2025-08-31 10:29:58.869] [undefined] GET(/:id/stats): try to get stats
[2025-08-31 10:29:58.875] [undefined] GET(/:id): Successfully get channel with id 1 with status 200 [2025-08-31 10:29:58.875] [undefined] GET(/:id): Successfully get channel with id 1 with status 200
[2025-08-31 10:29:58.885] [undefined] GET(/:id/stats): Successfully get stats with status 200 [2025-08-31 10:29:58.885] [undefined] GET(/:id/stats): Successfully get stats with status 200
[2025-08-31 10:30:58.389] [undefined] GET(/see-later): 'See Later' playlist retrieved for user with id 1 with status 200
[2025-09-03 17:34:12.979] [undefined] GET(/see-later): 'See Later' playlist retrieved for user with id 1 with status 200
[2025-09-03 17:34:15.647] [undefined] GET(/:id): failed due to invalid values with status 400
[2025-09-03 17:34:15.660] [undefined] GET(/:id/similar): failed due to invalid values with status 400
[2025-09-03 17:34:15.671] [undefined] GET(/user/:id): Playlists retrieved for user with id 1 with status 200
[2025-09-03 17:34:15.736] [undefined] GET(/:id/views): failed due to invalid values with status 400
[2025-09-03 17:34:24.176] [undefined] GET(/see-later): 'See Later' playlist retrieved for user with id 1 with status 200
[2025-09-03 17:34:26.470] [undefined] GET(/:id): failed due to invalid values with status 400
[2025-09-03 17:34:26.478] [undefined] GET(/user/:id): Playlists retrieved for user with id 1 with status 200
[2025-09-03 17:34:26.485] [undefined] GET(/:id/similar): failed due to invalid values with status 400
[2025-09-03 17:34:26.494] [undefined] GET(/:id/views): failed due to invalid values with status 400
[2025-09-03 17:34:26.941] [undefined] GET(/see-later): 'See Later' playlist retrieved for user with id 1 with status 200
[2025-09-03 17:34:29.468] [undefined] GET(/:id/history): try to retrieve history of user 1
[2025-09-03 17:34:29.523] [undefined] GET(/:id/history): successfully retrieved history of user 1 with status 200
[2025-09-03 17:34:29.535] [undefined] GET(/:id/channel): try to retrieve channel of user 1
[2025-09-03 17:34:29.541] [undefined] GET(/:id/channel): successfully retrieved channel of user 1 with status 200
[2025-09-03 17:34:29.550] [undefined] GET(/user/:id): Playlists retrieved for user with id 1 with status 200
[2025-09-03 17:34:30.404] [undefined] GET(/:id): Playlist retrieved with id 1 with status 200
[2025-09-03 17:34:31.607] [undefined] DELETE(/:id/video/:videoId): Video deleted from playlist with id 1 with status 200
[2025-09-03 17:34:31.690] [undefined] GET(/:id): Playlist retrieved with id 1 with status 200
[2025-09-03 17:34:32.741] [undefined] GET(/see-later): 'See Later' playlist retrieved for user with id 1 with status 200
[2025-09-03 17:34:41.091] [undefined] GET(/see-later): 'See Later' playlist retrieved for user with id 1 with status 200
[2025-09-03 17:35:57.790] [undefined] GET(/see-later): 'See Later' playlist retrieved for user with id 1 with status 200

Loading…
Cancel
Save