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

[#629] Added in range query for pagination for bbs and tps get accounts api #630

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

bsdworkin
Copy link
Collaborator

Description

Please provide a summary of the pull request and the issue it resolves. Please add necessary details, context, dependencies, explanation of when review is needed (see next section), etc.

**Resolves #629 **

Review Time Estimate

Please give your idea of how soon this pull request needs to be reviewed by selecting one of the options below. This can be based on the criticality of the issue at hand and/or other relevant factors.

  • Immediately
  • Within a week
  • When possible

Type of changes

Please select a relevant option:

  • Bug fix (non-breaking change which fixes an issue).
  • New feature (non-breaking change which adds functionality).
  • Breaking change (fix or feature that would cause existing functionality to not work as expected).
  • Other (any another change that does not fall in one of the above categories.)

Checklist:

Please select all applicable options:

  • I have signed the Rokwire Contributor License Agreement (CLA). (Any contributor who is not an employee of the University of Illinois whose official duties include contributing to the Rokwire software, or who is not paid by the Rokwire project, needs to sign the CLA before their contribution can be accepted.)
  • I have updated the CHANGELOG.
  • I have read the Contributor Guidelines.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • My change requires updating the documentation.
  • I have made necessary changes to the documentation.
  • I have added tests related to my changes.
  • My changes generate no new warnings.
  • New and existing unit tests pass locally with my changes.
  • Any dependent changes have been merged and published in downstream modules.

Copy link
Collaborator

@shurwit shurwit left a comment

Choose a reason for hiding this comment

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

Thanks @bsdworkin, this looks close! I left a few comments below with some issues I noticed. Let me know if you have any questions about the intended functionality or how to test.

options.SetLimit(int64(limit))
options.SetSkip(int64(offset))
} else {
filter = bson.M{"_id": bson.M{"$lt": rangeIndex}}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since we are sorting the documents in ascending order I think you want to use $gt here

Comment on lines +1210 to +1211
searchParams["app_org_id"] = appOrgIDs
filter = sa.getFilterForParams(searchParams)
Copy link
Collaborator

Choose a reason for hiding this comment

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

We need to apply the search params to the filter in both cases here. With the current setup it will ignore the query filters if you attempt to do pagination using the new method.

@@ -1188,7 +1188,7 @@ func (sa *Adapter) FindAccounts(context TransactionContext, limit *int, offset *
}

// FindAccountsByParams finds accounts by an arbitrary set of search params
func (sa *Adapter) FindAccountsByParams(searchParams map[string]interface{}, appID string, orgID string, limit int, offset int, allAccess bool, approvedKeys []string) ([]map[string]interface{}, error) {
func (sa *Adapter) FindAccountsByParams(searchParams map[string]interface{}, appID string, orgID string, limit int, offset int, allAccess bool, approvedKeys []string, rangeIndex string) ([]map[string]interface{}, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the name rangeIndex is somewhat unclear. I would suggest something like pageStartID or something similar to make it clear that this value is the ID of the item that marks the start of the next page.

@@ -41,6 +41,14 @@ post:
explode: false
schema:
type: integer
- name: range_index
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the name range_index is somewhat unclear. I would suggest something like page_start_id or something similar to make it clear that this value is the ID of the item that marks the start of the next page (first id not included in the next page). In the description we should also indicate that this should be the id of the last item that was retrieved on the previous page.

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.

[BUG] Pagination inconsistent on BBs and TPS accounts endpoints
2 participants