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

Make the CLI follow the nextKey for app and users #762

Merged
merged 7 commits into from
Dec 29, 2018

Conversation

XVincentX
Copy link
Member

@XVincentX XVincentX commented Jun 27, 2018

This PR introduces an additional flag for eg apps list and eg users list called -a or --all. When this is provided, the cli will navigate through the paged results from Redis in order to show all the users and not just the first page.

Connect #749
Closes #749

P.S: The CLI and the tests for the CLI have a lot of copy/paste code that could be removed and reused across the whole part of the system. However doing this now would be a significant amount of time. I still want to do that, but maybe in another iteration.

@XVincentX XVincentX force-pushed the bugfix/app-user-list-follow-pointer branch 2 times, most recently from 1068e73 to 3089255 Compare June 27, 2018 13:39
@codecov
Copy link

codecov bot commented Jun 27, 2018

Codecov Report

Merging #762 into master will decrease coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #762      +/-   ##
==========================================
- Coverage   89.13%   89.11%   -0.03%     
==========================================
  Files         131      132       +1     
  Lines        3591     3574      -17     
==========================================
- Hits         3201     3185      -16     
+ Misses        390      389       -1
Impacted Files Coverage Δ
lib/rest/routes/users.js 83.33% <100%> (-0.76%) ⬇️
admin/users.js 100% <100%> (ø) ⬆️
bin/generators/apps/list.js 92.85% <100%> (ø) ⬆️
admin/apps.js 100% <100%> (ø) ⬆️
bin/generators/users/list.js 92.85% <100%> (ø) ⬆️
bin/index.js 75% <0%> (-5%) ⬇️
lib/config/config.js 85.33% <0%> (-2.04%) ⬇️
lib/policies/proxy/proxy.js 96.42% <0%> (-0.3%) ⬇️
lib/rest/index.js 93.75% <0%> (-0.25%) ⬇️
lib/logger.js 100% <0%> (ø) ⬆️
... and 9 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d56d89f...b1f5a70. Read the comment docs.

Copy link
Member

@kevinswiber kevinswiber 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 changes suggested for descriptions in the CLI help text.

All in all, this whole thing is a bit weird. We paginate the results, but we don't have any parameters like --start-key or --limit. I wouldn't hold up this PR for that, but it's worth mentioning.

@@ -10,12 +10,13 @@ module.exports = class extends eg.Generator {
builder: yargs =>
yargs
.usage(`Usage: $0 ${process.argv[2]} list [options]`)
.boolean('a').alias('a', 'all').describe('a', 'Show all the elements instead of stopping to the fist page')
Copy link
Member

Choose a reason for hiding this comment

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

Suggest change in description:

List all apps

Copy link
Member Author

Choose a reason for hiding this comment

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

Done in f42d8d1

@@ -10,11 +10,12 @@ module.exports = class extends eg.Generator {
builder: yargs =>
yargs
.usage(`Usage: $0 ${process.argv[2]} list [options]`)
.boolean('a').alias('a', 'all').describe('a', 'Show all the elements instead of stopping to the fist page')
Copy link
Member

Choose a reason for hiding this comment

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

Suggest change in description:

List all users.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done in f42d8d1

@XVincentX XVincentX force-pushed the bugfix/app-user-list-follow-pointer branch from c7bab66 to f42d8d1 Compare July 10, 2018 10:10
@XVincentX
Copy link
Member Author

I agree with your points — the CLI is way behind what the API offers. I do hope we'll have some time to modernize the CLI and catch up with the API features.

@XVincentX
Copy link
Member Author

@kevinswiber I addressed the comments. If there's anything else here, we could bring this in.

@XVincentX
Copy link
Member Author

@DrMegavolt @kevinswiber Ping

Copy link
Contributor

@DrMegavolt DrMegavolt left a comment

Choose a reason for hiding this comment

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

While auto paging in CLI may work for this specific use case, but we have API that should be able to get all users.

See line reference where count parameter should be used. probably some may be required to actually propagate the parameter

list (params = {}) {
let results = [];

const fetchNext = (res) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

why do you need this page by page loader if you can request all users\apps at once
by passing count parameter as something big like Number.MAX_SAFE_INTEGER

dao.findAll = function ({ start = 0, count = '100' } = {}) {

Copy link
Member Author

Choose a reason for hiding this comment

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

Using a large number in theory guarantees that I get all the users — in practice we can't never be completely sure. We do not know how large the data base is.

Also — if I recall correctly the count is about the number of fields, not the number of records.

I do not feel really comfortable in making a single call with a large number and cross the fingers that all will work accordingly. If it's a paginated resource, we should handle pagination.

@kevinswiber Thoughts?

@XVincentX XVincentX force-pushed the bugfix/app-user-list-follow-pointer branch from f42d8d1 to b1f5a70 Compare August 3, 2018 14:55
@XVincentX XVincentX assigned XVincentX and unassigned XVincentX Aug 16, 2018
@XVincentX XVincentX merged commit 26340cb into master Dec 29, 2018
@XVincentX XVincentX deleted the bugfix/app-user-list-follow-pointer branch December 29, 2018 12:04
gatherchou pushed a commit to yilu-tech/express-gateway that referenced this pull request Jul 29, 2021
…user-list-follow-pointer

Make the CLI follow the nextKey for app and users
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.

None yet

3 participants