mirror of
https://github.com/wekan/wekan.git
synced 2025-12-16 07:20:12 +01:00
Fix duplicated lists and do not show debug messages when env DEBUG is not true. Part 3.
Thanks to xet7 ! Fixes #5952
This commit is contained in:
parent
1761f43afa
commit
58df525b49
5 changed files with 113 additions and 308 deletions
|
|
@ -15,7 +15,9 @@ Meteor.methods({
|
|||
throw new Meteor.Error('not-authorized');
|
||||
}
|
||||
|
||||
console.log('Starting duplicate lists fix for all boards...');
|
||||
if (process.env.DEBUG === 'true') {
|
||||
console.log('Starting duplicate lists fix for all boards...');
|
||||
}
|
||||
|
||||
const allBoards = Boards.find({}).fetch();
|
||||
let totalFixed = 0;
|
||||
|
|
@ -27,7 +29,7 @@ Meteor.methods({
|
|||
totalFixed += result.fixed;
|
||||
totalBoardsProcessed++;
|
||||
|
||||
if (result.fixed > 0) {
|
||||
if (result.fixed > 0 && process.env.DEBUG === 'true') {
|
||||
console.log(`Fixed ${result.fixed} duplicate lists in board "${board.title}" (${board._id})`);
|
||||
}
|
||||
} catch (error) {
|
||||
|
|
@ -35,7 +37,9 @@ Meteor.methods({
|
|||
}
|
||||
}
|
||||
|
||||
console.log(`Duplicate lists fix completed. Processed ${totalBoardsProcessed} boards, fixed ${totalFixed} duplicate lists.`);
|
||||
if (process.env.DEBUG === 'true') {
|
||||
console.log(`Duplicate lists fix completed. Processed ${totalBoardsProcessed} boards, fixed ${totalFixed} duplicate lists.`);
|
||||
}
|
||||
|
||||
return {
|
||||
message: `Fixed ${totalFixed} duplicate lists across ${totalBoardsProcessed} boards`,
|
||||
|
|
@ -55,7 +59,9 @@ Meteor.methods({
|
|||
},
|
||||
|
||||
fixDuplicateListsForBoard(boardId) {
|
||||
console.log(`Fixing duplicate lists for board ${boardId}...`);
|
||||
if (process.env.DEBUG === 'true') {
|
||||
console.log(`Fixing duplicate lists for board ${boardId}...`);
|
||||
}
|
||||
|
||||
// First, fix duplicate swimlanes
|
||||
const swimlaneResult = this.fixDuplicateSwimlanes(boardId);
|
||||
|
|
@ -94,7 +100,9 @@ Meteor.methods({
|
|||
const keepSwimlane = group[0];
|
||||
const removeSwimlanes = group.slice(1);
|
||||
|
||||
console.log(`Found ${group.length} duplicate swimlanes with title "${title}", keeping oldest (${keepSwimlane._id})`);
|
||||
if (process.env.DEBUG === 'true') {
|
||||
console.log(`Found ${group.length} duplicate swimlanes with title "${title}", keeping oldest (${keepSwimlane._id})`);
|
||||
}
|
||||
|
||||
// Move all lists from duplicate swimlanes to the kept swimlane
|
||||
removeSwimlanes.forEach(swimlane => {
|
||||
|
|
@ -116,11 +124,15 @@ Meteor.methods({
|
|||
);
|
||||
// Remove duplicate list
|
||||
Lists.remove(list._id);
|
||||
console.log(`Moved cards from duplicate list "${list.title}" to existing list in kept swimlane`);
|
||||
if (process.env.DEBUG === 'true') {
|
||||
console.log(`Moved cards from duplicate list "${list.title}" to existing list in kept swimlane`);
|
||||
}
|
||||
} else {
|
||||
// Move list to kept swimlane
|
||||
Lists.update(list._id, { $set: { swimlaneId: keepSwimlane._id } });
|
||||
console.log(`Moved list "${list.title}" to kept swimlane`);
|
||||
if (process.env.DEBUG === 'true') {
|
||||
console.log(`Moved list "${list.title}" to kept swimlane`);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -157,7 +169,9 @@ Meteor.methods({
|
|||
const keepList = group[0];
|
||||
const removeLists = group.slice(1);
|
||||
|
||||
console.log(`Found ${group.length} duplicate lists with title "${keepList.title}" in swimlane ${keepList.swimlaneId}, keeping oldest (${keepList._id})`);
|
||||
if (process.env.DEBUG === 'true') {
|
||||
console.log(`Found ${group.length} duplicate lists with title "${keepList.title}" in swimlane ${keepList.swimlaneId}, keeping oldest (${keepList._id})`);
|
||||
}
|
||||
|
||||
// Move all cards from duplicate lists to the kept list
|
||||
removeLists.forEach(list => {
|
||||
|
|
@ -170,7 +184,9 @@ Meteor.methods({
|
|||
// Remove duplicate list
|
||||
Lists.remove(list._id);
|
||||
fixed++;
|
||||
console.log(`Moved cards from duplicate list "${list.title}" to kept list`);
|
||||
if (process.env.DEBUG === 'true') {
|
||||
console.log(`Moved cards from duplicate list "${list.title}" to kept list`);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -55,7 +55,9 @@ class FixMissingListsMigration {
|
|||
for (const card of cards) {
|
||||
const expectedSwimlaneId = listSwimlaneMap.get(card.listId);
|
||||
if (expectedSwimlaneId && expectedSwimlaneId !== card.swimlaneId) {
|
||||
console.log(`Found mismatched card: ${card._id}, listId: ${card.listId}, card swimlaneId: ${card.swimlaneId}, list swimlaneId: ${expectedSwimlaneId}`);
|
||||
if (process.env.DEBUG === 'true') {
|
||||
console.log(`Found mismatched card: ${card._id}, listId: ${card.listId}, card swimlaneId: ${card.swimlaneId}, list swimlaneId: ${expectedSwimlaneId}`);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -72,7 +74,9 @@ class FixMissingListsMigration {
|
|||
*/
|
||||
async executeMigration(boardId) {
|
||||
try {
|
||||
console.log(`Starting fix missing lists migration for board ${boardId}`);
|
||||
if (process.env.DEBUG === 'true') {
|
||||
console.log(`Starting fix missing lists migration for board ${boardId}`);
|
||||
}
|
||||
|
||||
const board = ReactiveCache.getBoard(boardId);
|
||||
if (!board) {
|
||||
|
|
@ -165,7 +169,9 @@ class FixMissingListsMigration {
|
|||
targetList = { _id: newListId, ...newListData };
|
||||
createdLists++;
|
||||
|
||||
console.log(`Created new list "${originalList.title}" for swimlane ${swimlaneId}`);
|
||||
if (process.env.DEBUG === 'true') {
|
||||
console.log(`Created new list "${originalList.title}" for swimlane ${swimlaneId}`);
|
||||
}
|
||||
}
|
||||
|
||||
// Update all cards in this group to use the correct listId
|
||||
|
|
@ -189,7 +195,9 @@ class FixMissingListsMigration {
|
|||
}
|
||||
});
|
||||
|
||||
console.log(`Fix missing lists migration completed for board ${boardId}: created ${createdLists} lists, updated ${updatedCards} cards`);
|
||||
if (process.env.DEBUG === 'true') {
|
||||
console.log(`Fix missing lists migration completed for board ${boardId}: created ${createdLists} lists, updated ${updatedCards} cards`);
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue