-
Notifications
You must be signed in to change notification settings - Fork 2
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
Looping through all rapidpro contacts #2
base: master
Are you sure you want to change the base?
Conversation
|
||
rapidpro.getContacts(groupUUID, getContactsCallback([])) | ||
|
||
let url = rapidpro.contactsURL(groupUUID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
contactsURL
is not a public function so you can't use it like this. Is there a reason you need to do it like this rather than how it was before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need to add in paging parameters?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes,because i will now be looping through the getContacts(),so i just want it to accept a url other than groupUUID
@@ -53,10 +53,9 @@ module.exports = function (config) { | |||
}) | |||
} | |||
|
|||
const getContacts = function (groupUUID, callback) { | |||
let url = contactsURL(groupUUID) | |||
const getContacts = function (url, callback) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think rather than passing in a URL here we should rather keep it how it was before and rather add the paging parameters as a parameter to this call. We could make the parameter optional by doing something like this:
const getContacts = function (url, page, callback) {
if (typeof page === 'function') {
callback = page
page = null
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
let before = new Date() | ||
|
||
let options = { | ||
url: url, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should then add the query parameter for pagination to the url here.
let next = JSON.parse(body).next | ||
if(next) { | ||
winston.error(next) | ||
getContacts(next) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This recursive call will then just pass the correct page parameter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so we dont pass the call back function on this call?
No description provided.