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

filter members option in user API #1001

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

Conversation

vinayak-trivedi
Copy link
Member

closes #1000

models/users.js Show resolved Hide resolved
expect(response.body.links).to.have.property("prev");

expect(response.body.users[0].roles.member).to.be.equal(true);
expect(response.body.users[0].roles.archived).to.be.equal(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

can we also test the length of the response returned?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we do not need to test it

Comment on lines +133 to +151
if (query.member === "true") {
const membersArray = [];
const snapshot = await userModel.where("roles.member", "==", true).where("roles.archived", "==", false).get();
if (!snapshot.empty) {
snapshot.forEach((doc) => {
membersArray.push({
id: doc.id,
...doc.data(),
phone: undefined,
email: undefined,
tokens: undefined,
chaincode: undefined,
});
});
}
return {
allUsers: membersArray,
};
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Please handle this in the bottom part, where users are being fetched. We are just repeating code here.
There is no pagination here, even though user API has pagination.

And instead of having a key where member=true, let's generic field like a filter or role
Where we pass filterBy=MEMBERS, filterBy=AO or role=ARCHIVED, role=NEW, with paginations

@prakashchoudhary07
Copy link
Contributor

Can you please share the data model and API contracts for it?

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.

Add filter for members on /users route
3 participants