chore: remove verbose reorder/debug logs and tidy XML export logs; streamline FE reorder console noise
This commit is contained in:
parent
5659dde540
commit
5f17380816
@ -154,8 +154,7 @@ router.post('/reorder-move', async (req: Request, res: Response) => {
|
|||||||
if (insertIndex < 0) insertIndex = without.length;
|
if (insertIndex < 0) insertIndex = without.length;
|
||||||
without.splice(insertIndex, 0, fromId);
|
without.splice(insertIndex, 0, fromId);
|
||||||
|
|
||||||
console.log('[REORDER_MOVE] playlist:', playlistName, 'from:', fromId, 'to:', toId, 'baseLen:', base.length, 'orderLenBefore:', order.length, 'orderLenAfter:', without.length);
|
// Updated playlist order overlay
|
||||||
console.log('[REORDER_MOVE] sample order:', without.slice(0, 5));
|
|
||||||
node.order = without; // store full order overlay
|
node.order = without; // store full order overlay
|
||||||
updated = true;
|
updated = true;
|
||||||
return node;
|
return node;
|
||||||
@ -219,8 +218,7 @@ router.post('/reorder-move-many', async (req: Request, res: Response) => {
|
|||||||
// Insert block preserving relative order
|
// Insert block preserving relative order
|
||||||
without.splice(insertIndex, 0, ...movingOrdered);
|
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);
|
// Updated playlist order overlay for batch move
|
||||||
console.log('[REORDER_MOVE_MANY] sample order:', without.slice(0, 7));
|
|
||||||
node.order = without;
|
node.order = without;
|
||||||
updated = true;
|
updated = true;
|
||||||
return node;
|
return node;
|
||||||
|
|||||||
@ -76,7 +76,7 @@ router.get('/playlist/*', async (req: Request, res: Response) => {
|
|||||||
const search = req.query.search as string || '';
|
const search = req.query.search as string || '';
|
||||||
const skip = (page - 1) * limit;
|
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
|
// Find the playlist recursively in the playlist structure
|
||||||
const findPlaylistRecursively = (nodes: any[], targetName: string): any => {
|
const findPlaylistRecursively = (nodes: any[], targetName: string): any => {
|
||||||
@ -102,9 +102,7 @@ router.get('/playlist/*', async (req: Request, res: Response) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!playlist) {
|
if (!playlist) {
|
||||||
console.log(`Playlist "${playlistName}" not found. Available playlists:`);
|
// Playlist not found
|
||||||
const allPlaylistNames = await Playlist.find({}, 'name');
|
|
||||||
console.log(allPlaylistNames.map(p => p.name));
|
|
||||||
return res.status(404).json({ message: `Playlist "${playlistName}" 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);
|
const trackIds = getAllTrackIds(playlist);
|
||||||
console.log(`[PLAYLIST_ORDER] ${playlistName} tracks count:`, trackIds.length);
|
// Compute effective ordered track IDs
|
||||||
console.log('[PLAYLIST_ORDER] first 10 ids:', trackIds.slice(0, 10));
|
|
||||||
|
|
||||||
if (trackIds.length === 0) {
|
if (trackIds.length === 0) {
|
||||||
return res.json({
|
return res.json({
|
||||||
@ -178,7 +175,6 @@ router.get('/playlist/*', async (req: Request, res: Response) => {
|
|||||||
const pageEnd = Math.min(pageStart + limit, trackIds.length);
|
const pageEnd = Math.min(pageStart + limit, trackIds.length);
|
||||||
const pageTrackIds = trackIds.slice(pageStart, pageEnd);
|
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 } })
|
const pageSongs = await Song.find({ id: { $in: pageTrackIds } })
|
||||||
.populate('s3File.musicFileId')
|
.populate('s3File.musicFileId')
|
||||||
.lean();
|
.lean();
|
||||||
@ -186,8 +182,6 @@ router.get('/playlist/*', async (req: Request, res: Response) => {
|
|||||||
for (const s of pageSongs) idToSong[s.id] = s;
|
for (const s of pageSongs) idToSong[s.id] = s;
|
||||||
const songs = pageTrackIds.map(id => idToSong[id]).filter(Boolean);
|
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({
|
res.json({
|
||||||
songs,
|
songs,
|
||||||
pagination: {
|
pagination: {
|
||||||
|
|||||||
@ -40,7 +40,7 @@ const buildXmlNode = (node: any): any => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const streamToXml = async (res: 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)
|
// Write XML header with encoding (like master collection)
|
||||||
res.write('<?xml version="1.0" encoding="UTF-8"?>');
|
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"/>');
|
res.write('\n <PRODUCT Name="rekordbox" Version="7.1.3" Company="AlphaTheta"/>');
|
||||||
|
|
||||||
// Start COLLECTION section
|
// Start COLLECTION section
|
||||||
console.log('Counting songs in database...');
|
|
||||||
const songCount = await Song.countDocuments();
|
const songCount = await Song.countDocuments();
|
||||||
console.log(`Found ${songCount} songs in database`);
|
|
||||||
res.write(`\n <COLLECTION Entries="${songCount}">`);
|
res.write(`\n <COLLECTION Entries="${songCount}">`);
|
||||||
|
|
||||||
// Stream songs in batches to avoid memory issues
|
// Stream songs in batches to avoid memory issues
|
||||||
@ -78,7 +76,6 @@ export const streamToXml = async (res: any) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
processedSongs += songs.length;
|
processedSongs += songs.length;
|
||||||
console.log(`Streamed ${processedSongs}/${songCount} songs...`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
res.write('\n </COLLECTION>');
|
res.write('\n </COLLECTION>');
|
||||||
@ -87,9 +84,7 @@ export const streamToXml = async (res: any) => {
|
|||||||
res.write('\n <PLAYLISTS>');
|
res.write('\n <PLAYLISTS>');
|
||||||
|
|
||||||
// Stream playlists
|
// Stream playlists
|
||||||
console.log('Fetching playlists from database...');
|
|
||||||
const playlists = await Playlist.find({}).lean();
|
const playlists = await Playlist.find({}).lean();
|
||||||
console.log(`Found ${playlists.length} playlists in database`);
|
|
||||||
|
|
||||||
// Write ROOT node with correct Count
|
// Write ROOT node with correct Count
|
||||||
res.write(`\n <NODE Type="0" Name="ROOT" Count="${playlists.length}">`);
|
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.write('\n</DJ_PLAYLISTS>');
|
||||||
|
|
||||||
res.end();
|
res.end();
|
||||||
|
console.log('XML export completed.');
|
||||||
};
|
};
|
||||||
|
|
||||||
const streamPlaylistNodeFull = async (res: any, node: any) => {
|
const streamPlaylistNodeFull = async (res: any, node: any) => {
|
||||||
|
|||||||
@ -298,27 +298,16 @@ export const PaginatedSongList: React.FC<PaginatedSongListProps> = memo(({
|
|||||||
}
|
}
|
||||||
} catch {}
|
} catch {}
|
||||||
}
|
}
|
||||||
if (!fromId && !multiIds) {
|
if (!fromId && !multiIds) return;
|
||||||
console.debug('[Reorder] missing fromId');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const fromIndex = fromId ? songs.findIndex(s => s.id === fromId) : -1;
|
const fromIndex = fromId ? songs.findIndex(s => s.id === fromId) : -1;
|
||||||
const toIndex = index;
|
const toIndex = index;
|
||||||
if (fromIndex < 0 || toIndex < 0) {
|
if (fromIndex < 0 || toIndex < 0) return;
|
||||||
console.debug('[Reorder] invalid indexes', { fromIndex, toIndex });
|
if (fromIndex === toIndex) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (fromIndex === toIndex) {
|
|
||||||
console.debug('[Reorder] same index drop');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const toId = songs[index].id;
|
const toId = songs[index].id;
|
||||||
// If multiple, move block; else move single
|
// If multiple, move block; else move single
|
||||||
if (multiIds && multiIds.length > 0) {
|
if (multiIds && multiIds.length > 0) {
|
||||||
console.debug('[Reorder] move many request', { playlist: currentPlaylist, fromIds: multiIds, toId });
|
|
||||||
await api.moveTracksInPlaylist(currentPlaylist, multiIds, toId);
|
await api.moveTracksInPlaylist(currentPlaylist, multiIds, toId);
|
||||||
} else {
|
} else {
|
||||||
console.debug('[Reorder] move request', { playlist: currentPlaylist, fromId, toId });
|
|
||||||
await api.moveTrackInPlaylist(currentPlaylist, fromId!, toId);
|
await api.moveTrackInPlaylist(currentPlaylist, fromId!, toId);
|
||||||
}
|
}
|
||||||
await onReorder(songs.map(s => s.id)); // trigger refresh via parent
|
await onReorder(songs.map(s => s.id)); // trigger refresh via parent
|
||||||
@ -326,10 +315,9 @@ export const PaginatedSongList: React.FC<PaginatedSongListProps> = memo(({
|
|||||||
setIsReorderDragging(false);
|
setIsReorderDragging(false);
|
||||||
}}
|
}}
|
||||||
onRowDragStartCapture={(e: React.DragEvent) => {
|
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;
|
if (!currentPlaylist || selectedSongs.size > 0) return;
|
||||||
e.dataTransfer.setData('text/song-id', song.id);
|
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
|
// Explicitly set effect to move for better UX
|
||||||
try { e.dataTransfer.effectAllowed = 'move'; } catch {}
|
try { e.dataTransfer.effectAllowed = 'move'; } catch {}
|
||||||
try { e.dataTransfer.dropEffect = 'move'; } catch {}
|
try { e.dataTransfer.dropEffect = 'move'; } catch {}
|
||||||
@ -549,10 +537,8 @@ export const PaginatedSongList: React.FC<PaginatedSongListProps> = memo(({
|
|||||||
if (!fromId && !multiIds) return;
|
if (!fromId && !multiIds) return;
|
||||||
// Move to end: omit toId
|
// Move to end: omit toId
|
||||||
if (multiIds && multiIds.length > 0) {
|
if (multiIds && multiIds.length > 0) {
|
||||||
console.debug('[Reorder] move many to end request', { playlist: currentPlaylist, fromIds: multiIds });
|
|
||||||
await api.moveTracksInPlaylist(currentPlaylist, multiIds);
|
await api.moveTracksInPlaylist(currentPlaylist, multiIds);
|
||||||
} else {
|
} else {
|
||||||
console.debug('[Reorder] move to end request', { playlist: currentPlaylist, fromId });
|
|
||||||
await api.moveTrackInPlaylist(currentPlaylist, fromId!);
|
await api.moveTrackInPlaylist(currentPlaylist, fromId!);
|
||||||
}
|
}
|
||||||
await onReorder(songs.map(s => s.id));
|
await onReorder(songs.map(s => s.id));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user