Skip to content

Commit

Permalink
Merge pull request #714 from adessoSE/CUC-712-Import-Block-Duplicatio…
Browse files Browse the repository at this point in the history
…n-Fix

Cuc 712 import block duplication fix
  • Loading branch information
sMeilbeck authored Nov 29, 2024
2 parents fca7e2f + 1aaecb2 commit 88d5234
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 3 additions & 1 deletion backend/src/database/DbServices.js
Original file line number Diff line number Diff line change
Expand Up @@ -1762,8 +1762,10 @@ async function importBlocks(
);
singularBlock.repository = repoName;
singularBlock.repositoryId = importRepo;
if (!post && !importMode && singularBlock._id) {
if (!post && !importMode) {
singularBlock._id = findAssociatedID(singularBlock.name, allConflicts);
if(!singularBlock._id)
console.log("Error within findAssociatedID @ importBlocks");
await updateBlock(singularBlock._id, singularBlock, session, client);
} else {
await saveBlock(singularBlock, session, client);
Expand Down
11 changes: 9 additions & 2 deletions backend/src/helpers/projectManagement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ async function importProject(file, repo_id?, projectName?, importMode?) {
async function nameCheckStory() {
let conflictingNames = [];
const existingStories = await mongo.getAllStoriesOfRepo(repo_id);
console.log(existingStories);
const existingNames = existingStories.map(({ title, _id }) => ({
existingName: title,
associatedID: _id.toHexString(),
Expand Down Expand Up @@ -505,10 +506,11 @@ async function importProject(file, repo_id?, projectName?, importMode?) {
file,
allConflicts
);

await mongo.importBlocks(
false,
repo_id,
await mongo.getOneRepositoryById(repo_id).repoName,
repoData.repoName,
session,
existingNameList,
repoBlocksData,
Expand All @@ -518,6 +520,7 @@ async function importProject(file, repo_id?, projectName?, importMode?) {
client,
allConflicts
);

await mongo.importGroups(
false,
repo_id,
Expand Down Expand Up @@ -557,7 +560,8 @@ async function importProject(file, repo_id?, projectName?, importMode?) {
) {
console.log("Repository already existing!");
throw new Error(newRepo); // Throw an error with the message
}
};

await mongo.importStories(
true,
newRepo.toHexString(),
Expand All @@ -572,6 +576,8 @@ async function importProject(file, repo_id?, projectName?, importMode?) {
file
);
console.log(groupMapping);
console.log(existingNameList);

await mongo.importBlocks(
true,
newRepo.toHexString(),
Expand All @@ -584,6 +590,7 @@ async function importProject(file, repo_id?, projectName?, importMode?) {
findAssociatedID,
client
);

await mongo.importGroups(
true,
newRepo.toHexString(),
Expand Down

0 comments on commit 88d5234

Please sign in to comment.