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

Add users filtering while exporting #362

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

mayank190801
Copy link
Contributor

Fixes issue #313

I have taken motivation from last pull request on this issue.

  • Now users can be exported on the basis of name, role and classrooms.
  • 'All' option is added, using which all users can be exported.

@mayank190801
Copy link
Contributor Author

@llaske please review it and lemme know if any changes are required.

@mayank190801
Copy link
Contributor Author

Few warnings are coming in console. Should I define them in locale.ini file?

Screenshot 2023-02-17 at 4 06 30 PM

@mayank190801
Copy link
Contributor Author

@codebloded can you review this once, and let me know if any changes are required?

@codebloded
Copy link
Contributor

yes !

function downloadUsers(event) {
$.ajax({
type: "GET",
url: "/dashboard/users/export",
url: `/dashboard/users/export/${roleValue}/${usernameValue}/${classroomValue}`,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead of making these parameters part of the URL, it'll be better group them in a query.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, that makes more sense.

Comment on lines +181 to +204
var filteredUsers = [];
var requiredIDs = new Set();
if(selectedClassroom !== 'undefined'){
selectedClassroom.split(',').forEach(id => {
requiredIDs.add(id);
});
}
users.forEach(user => {
let required = true;
if (selectedUsername !== 'undefined') {
if (user.name !== selectedUsername) {
required = false;
}
}
if (required && selectedRole !== 'all' && user.type !== selectedRole) {
required = false;
}
if (required && selectedRole === 'student' && selectedClassroom !== 'undefined') {
if (!requiredIDs.has(user._id)) {
required = false;
}
}
if(required) filteredUsers.push(user);
})
Copy link
Collaborator

Choose a reason for hiding this comment

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

  • Filtering logic can be simplified.
  • Some variable names are misleading, like requiredIDs.
  • Fix indentation.
  • Maybe consider using Array.filter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay I will look into it. Thank you for the feedback!

@mayank190801
Copy link
Contributor Author

I have been a little busy, so missed on completing this pull request. I will look into the changes. Thanks for the wait!

@llaske
Copy link
Owner

llaske commented Apr 30, 2023

@mayank190801 sounds like there a lint issue. Could you fix it?

@mayank190801
Copy link
Contributor Author

I have created another pull request #404 regarding this issue. We can continue our discussion there. Thanks.

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

Successfully merging this pull request may close these issues.

4 participants