chore: remove verbose reorder/debug logs and tidy XML export logs; streamline FE reorder console noise

This commit is contained in:
Geert Rademakes 2025-08-08 15:05:10 +02:00
parent 5659dde540
commit 5f17380816
4 changed files with 11 additions and 37 deletions

View File

@ -154,8 +154,7 @@ router.post('/reorder-move', async (req: Request, res: Response) => {
if (insertIndex < 0) insertIndex = without.length;
without.splice(insertIndex, 0, fromId);
console.log('[REORDER_MOVE] playlist:', playlistName, 'from:', fromId, 'to:', toId, 'baseLen:', base.length, 'orderLenBefore:', order.length, 'orderLenAfter:', without.length);
console.log('[REORDER_MOVE] sample order:', without.slice(0, 5));
// Updated playlist order overlay
node.order = without; // store full order overlay
updated = true;
return node;
@ -219,8 +218,7 @@ router.post('/reorder-move-many', async (req: Request, res: Response) => {
// Insert block preserving relative order
without.splice(insertIndex, 0, ...movingOrdered);
console.log('[REORDER_MOVE_MANY] playlist:', playlistName, 'count:', movingOrdered.length, 'to:', toId, 'baseLen:', base.length, 'orderLenBefore:', order.length, 'orderLenAfter:', without.length);
console.log('[REORDER_MOVE_MANY] sample order:', without.slice(0, 7));
// Updated playlist order overlay for batch move
node.order = without;
updated = true;
return node;

View File

@ -76,7 +76,7 @@ router.get('/playlist/*', async (req: Request, res: Response) => {
const search = req.query.search as string || '';
const skip = (page - 1) * limit;
console.log(`Fetching songs for playlist "${playlistName}"... Page: ${page}, Limit: ${limit}, Search: "${search}"`);
// Fetch songs for playlist with pagination
// Find the playlist recursively in the playlist structure
const findPlaylistRecursively = (nodes: any[], targetName: string): any => {
@ -102,9 +102,7 @@ router.get('/playlist/*', async (req: Request, res: Response) => {
}
if (!playlist) {
console.log(`Playlist "${playlistName}" not found. Available playlists:`);
const allPlaylistNames = await Playlist.find({}, 'name');
console.log(allPlaylistNames.map(p => p.name));
// Playlist not found
return res.status(404).json({ message: `Playlist "${playlistName}" not found` });
}
@ -126,8 +124,7 @@ router.get('/playlist/*', async (req: Request, res: Response) => {
};
const trackIds = getAllTrackIds(playlist);
console.log(`[PLAYLIST_ORDER] ${playlistName} tracks count:`, trackIds.length);
console.log('[PLAYLIST_ORDER] first 10 ids:', trackIds.slice(0, 10));
// Compute effective ordered track IDs
if (trackIds.length === 0) {
return res.json({
@ -178,7 +175,6 @@ router.get('/playlist/*', async (req: Request, res: Response) => {
const pageEnd = Math.min(pageStart + limit, trackIds.length);
const pageTrackIds = trackIds.slice(pageStart, pageEnd);
console.log('[PLAYLIST_ORDER] page', page, 'limit', limit, 'slice', pageStart, pageEnd, 'ids:', pageTrackIds);
const pageSongs = await Song.find({ id: { $in: pageTrackIds } })
.populate('s3File.musicFileId')
.lean();
@ -186,8 +182,6 @@ router.get('/playlist/*', async (req: Request, res: Response) => {
for (const s of pageSongs) idToSong[s.id] = s;
const songs = pageTrackIds.map(id => idToSong[id]).filter(Boolean);
console.log(`Found ${songs.length} songs for playlist "${playlistName}" (${totalSongs} total), ${songs.filter((s: any) => s.s3File?.hasS3File).length} with S3 files`);
res.json({
songs,
pagination: {

View File

@ -40,7 +40,7 @@ const buildXmlNode = (node: any): any => {
};
export const streamToXml = async (res: any) => {
console.log('Starting streamToXml function...');
console.log('Starting XML export...');
// Write XML header with encoding (like master collection)
res.write('<?xml version="1.0" encoding="UTF-8"?>');
@ -50,9 +50,7 @@ export const streamToXml = async (res: any) => {
res.write('\n <PRODUCT Name="rekordbox" Version="7.1.3" Company="AlphaTheta"/>');
// Start COLLECTION section
console.log('Counting songs in database...');
const songCount = await Song.countDocuments();
console.log(`Found ${songCount} songs in database`);
res.write(`\n <COLLECTION Entries="${songCount}">`);
// Stream songs in batches to avoid memory issues
@ -78,7 +76,6 @@ export const streamToXml = async (res: any) => {
}
processedSongs += songs.length;
console.log(`Streamed ${processedSongs}/${songCount} songs...`);
}
res.write('\n </COLLECTION>');
@ -87,9 +84,7 @@ export const streamToXml = async (res: any) => {
res.write('\n <PLAYLISTS>');
// Stream playlists
console.log('Fetching playlists from database...');
const playlists = await Playlist.find({}).lean();
console.log(`Found ${playlists.length} playlists in database`);
// Write ROOT node with correct Count
res.write(`\n <NODE Type="0" Name="ROOT" Count="${playlists.length}">`);
@ -103,6 +98,7 @@ export const streamToXml = async (res: any) => {
res.write('\n</DJ_PLAYLISTS>');
res.end();
console.log('XML export completed.');
};
const streamPlaylistNodeFull = async (res: any, node: any) => {

View File

@ -298,27 +298,16 @@ export const PaginatedSongList: React.FC<PaginatedSongListProps> = memo(({
}
} catch {}
}
if (!fromId && !multiIds) {
console.debug('[Reorder] missing fromId');
return;
}
if (!fromId && !multiIds) return;
const fromIndex = fromId ? songs.findIndex(s => s.id === fromId) : -1;
const toIndex = index;
if (fromIndex < 0 || toIndex < 0) {
console.debug('[Reorder] invalid indexes', { fromIndex, toIndex });
return;
}
if (fromIndex === toIndex) {
console.debug('[Reorder] same index drop');
return;
}
if (fromIndex < 0 || toIndex < 0) return;
if (fromIndex === toIndex) return;
const toId = songs[index].id;
// If multiple, move block; else move single
if (multiIds && multiIds.length > 0) {
console.debug('[Reorder] move many request', { playlist: currentPlaylist, fromIds: multiIds, toId });
await api.moveTracksInPlaylist(currentPlaylist, multiIds, toId);
} else {
console.debug('[Reorder] move request', { playlist: currentPlaylist, fromId, toId });
await api.moveTrackInPlaylist(currentPlaylist, fromId!, toId);
}
await onReorder(songs.map(s => s.id)); // trigger refresh via parent
@ -326,10 +315,9 @@ export const PaginatedSongList: React.FC<PaginatedSongListProps> = memo(({
setIsReorderDragging(false);
}}
onRowDragStartCapture={(e: React.DragEvent) => {
// Provide a simple id for intra-list reorder
// Provide a simple id for intra-list reorder
if (!currentPlaylist || selectedSongs.size > 0) return;
e.dataTransfer.setData('text/song-id', song.id);
console.debug('[Reorder] drag start', { id: song.id, index });
// Explicitly set effect to move for better UX
try { e.dataTransfer.effectAllowed = 'move'; } catch {}
try { e.dataTransfer.dropEffect = 'move'; } catch {}
@ -549,10 +537,8 @@ export const PaginatedSongList: React.FC<PaginatedSongListProps> = memo(({
if (!fromId && !multiIds) return;
// Move to end: omit toId
if (multiIds && multiIds.length > 0) {
console.debug('[Reorder] move many to end request', { playlist: currentPlaylist, fromIds: multiIds });
await api.moveTracksInPlaylist(currentPlaylist, multiIds);
} else {
console.debug('[Reorder] move to end request', { playlist: currentPlaylist, fromId });
await api.moveTrackInPlaylist(currentPlaylist, fromId!);
}
await onReorder(songs.map(s => s.id));