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

OCLOMRS-58: paginate concepts in a dictionary #70

Merged
merged 1 commit into from
Jul 17, 2018

Conversation

emasys
Copy link
Contributor

@emasys emasys commented Jul 16, 2018

JIRA TICKET NAME:

As a user, I should be able to see all the concepts in my dictionary with proper pagination

Summary:

Return all concepts in a particular dictionary with proper paginations.
each page should not have more than 10 results
each page should have a previous and next button
infinite scroll could be used but not necessarily

@emasys emasys force-pushed the OCLOMRS-58 branch 2 times, most recently from 3b5fee3 to e6f126e Compare July 16, 2018 08:22
@coveralls
Copy link

coveralls commented Jul 16, 2018

Pull Request Test Coverage Report for Build 355

  • 49 of 55 (89.09%) changed or added relevant lines in 7 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+1.0%) to 80.189%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/components/dictionaryConcepts/containers/DictionaryConcepts.jsx 8 9 88.89%
src/components/dictionaryConcepts/containers/CreateConcept.jsx 0 2 0.0%
src/redux/actions/concepts/dictionaryConcepts.js 32 35 91.43%
Totals Coverage Status
Change from base Build 353: 1.0%
Covered Lines: 711
Relevant Lines: 824

💛 - Coveralls

Copy link
Collaborator

@hadijahkyampeire hadijahkyampeire left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@EleisonC EleisonC left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@shakirandagire shakirandagire left a comment

Choose a reason for hiding this comment

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

LGTM

}

fetchConcepts(query = '', limit = 10, filterParams = null, filterName = null) {
Copy link
Member

Choose a reason for hiding this comment

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

Does the change from limit 10 to 0 mean you are paginating from client instead of server?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, it's faster.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I also needed to get the total number of concepts at every point in time whether I'm searching or filtering.

Copy link
Member

Choose a reason for hiding this comment

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

What happens when a server has too many concepts? Do you still want to load all of them to the client?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, for now, that's the only way to get the total number of concepts while filtering by sources or class.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I understand what you are saying, my point is I need to get the total number of concepts each time I fetch the concepts from the server, right now it will not be possible if I use the limit parameter.

Copy link
Member

Choose a reason for hiding this comment

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

So with your change, are you simply getting the total number of concepts? Or are you actually getting the concepts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm getting the concepts. There's currently no way to get only the total number of concepts when filtering or searching.

Copy link
Member

Choose a reason for hiding this comment

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

So my point is, the original code was safer because it does not load all the concepts. And this was achieved by the use of the limit parameter. Getting rid of this parameter looks like a design mistake unless you can convince me otherwise.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The initial code was a quick hack, I only got the total number of concepts in a dictionary because I saved it in the localStorage. The issues with the initial code are as follows:

  • when a filter returns eleven concepts, the user will only see ten with no idea there could be more because there's no way to know if there's actually more.
  • The filter sidebar cannot be populated with items that are not available. i.e - if the first ten concepts are from the same source or class, the sidebar will be populated by only that type of source. This will clearly defeat the aim of having the sidebar.
  • There are other reasons why I have to fetch everything first, but I will stop here. Refer to the images below for more clarity about my second point.

with pagination

without pagination

@dkayiwa dkayiwa merged commit b3cbdcc into openmrs:master Jul 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants