Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Desktop: Batch delete for Notebooks added #2730

Merged
merged 10 commits into from Mar 14, 2020
Merged

Desktop: Batch delete for Notebooks added #2730

merged 10 commits into from Mar 14, 2020

Conversation

RedDocMD
Copy link
Contributor

Fixes #2703

@RedDocMD
Copy link
Contributor Author

@tessus, is this okay?

@tessus
Copy link
Collaborator

tessus commented Mar 11, 2020

Yes, looks good.

@tessus tessus added the desktop All desktop platforms label Mar 11, 2020
@tessus tessus changed the title Batch delete for Notebooks added Desktop: Batch delete for Notebooks added Mar 11, 2020
@RedDocMD
Copy link
Contributor Author

@laurent22, can this be merged?

@miciasto
Copy link
Contributor

@RedDocMD please do not send mentions for merge attention, your PR will not be lost, it will be processed in due course.

@miciasto
Copy link
Contributor

@RedDocMD

Are there unit tests for Note.batchDelete()? I know you did not create this method, however as your change relies on it, it is good practice to add them if they do not exist.

Have you reviewed the unit tests for Folder.delete(). Are there additional cases that we should add?

@RedDocMD
Copy link
Contributor Author

RedDocMD commented Mar 13, 2020

@mic704b , there doesn't seem to be a unit test for Note.batchDelete() in CliClient/tests/model_Note.js. I will add one. Also the unit test for Folder.delete() doesn't test for multiple notes across several sub-notebooks. So I will add that as well.

@RedDocMD
Copy link
Contributor Author

@mic704b, I have added the tests I had mentioned above

@RedDocMD
Copy link
Contributor Author

@PackElend, can you please add the GSoC tag for this PR?

@RedDocMD RedDocMD closed this Mar 13, 2020
@RedDocMD RedDocMD reopened this Mar 13, 2020
@laurent22
Copy link
Owner

Code looks good. @mic704b feel free to merge if the tests are good to go.

Copy link
Contributor

@miciasto miciasto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few of minor comments and we're good to go.

CliClient/tests/models_Note.js Outdated Show resolved Hide resolved
CliClient/tests/models_Note.js Show resolved Hide resolved
CliClient/tests/models_Note.js Show resolved Hide resolved
@RedDocMD
Copy link
Contributor Author

@mic704b, I have made the changes as you had instructed

Copy link
Contributor

@miciasto miciasto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @RedDocMD nice changes. Comments added to request a couple of refactors to use existing test utilities, and a simplification.

Also, please resolve merge conflicts.

Comment on lines 156 to 162
let noOfNotes = 20;
for (let i = 0; i < noOfNotes; i++) {
await Note.save({ title: `note1${i}`, parent_id: f1.id });
}
for (let i = 0; i < noOfNotes; i++) {
await Note.save({ title: `note2${i}`, parent_id: f2.id });
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead use createNTestNotes from test-utils.js (also applies to next test case)

CliClient/tests/models_Note.js Outdated Show resolved Hide resolved
Comment on lines 206 to 218
let noOfNotes = 20;
for (let i = 0; i < noOfNotes; i++) {
await Note.save({ title: `note1${i}`, parent_id: f1.id });
}
for (let i = 0; i < noOfNotes; i++) {
await Note.save({ title: `note2${i}`, parent_id: f2.id });
}
for (let i = 0; i < noOfNotes; i++) {
await Note.save({ title: `note3${i}`, parent_id: f3.id });
}
for (let i = 0; i < noOfNotes; i++) {
await Note.save({ title: `note4${i}`, parent_id: f4.id });
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use createNTestNotes for these

Comment on lines 224 to 229
expect(beforeDelete.length).toBe(afterDelete.length);
let count = 0;
for (let i = 0; i < beforeDelete.length; i++) {
if (beforeDelete[i].id == afterDelete[i].id) ++count;
}
expect(beforeDelete.length).toBe(count);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good

but you can reduce all of this to:

expect(sortedIds(afterDelete)).toEqual(sortedIds(beforeDelete));

let notesInFolder1IDs = await Folder.noteIds(f1.id);
let notesInFolder2IDs = await Folder.noteIds(f2.id);

const selectRandomly = (source, count) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. However lets not have a random element in the tests. Please remove and simplify this case a bit. If you want to cover more combinations, make extra test cases explicitly. I'd be happy with just one though, to start with.

Nice work though, you seem to know your javascript!

@RedDocMD
Copy link
Contributor Author

@mic704b, I have made the changes you said and resolved the conflict

@miciasto
Copy link
Contributor

Thanks @RedDocMD changes look good.

You've just got a few linter problems to fix.

@RedDocMD
Copy link
Contributor Author

@mic704b, I think I have fixed the linter issues

@miciasto miciasto merged commit bdd760f into laurent22:master Mar 14, 2020
@miciasto
Copy link
Contributor

Thanks @RedDocMD, all good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
desktop All desktop platforms
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Desktop: Deleting Notebook Slower Than Selecting All Notes and Hitting Delete
5 participants