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

Fix metadata forms filter #445

Merged
merged 2 commits into from Oct 22, 2022

Conversation

ezraporter
Copy link
Contributor

Closes #431

This PR fixes the issue with redcap_metadata_read returning all forms when specific forms are requested in the forms parameter. In doing this I also noticed that the same bug applies to the fields parameter so I implemented the fix there as well.

My solution was to add a small utility function to redcap-metadata-read.R that converts a vector into the right format, a list of key-value pairs to append to the request body.

@wibeasley
Copy link
Member

Thanks for doing this, @ezraporter. I was tweaking some of the test projects last night, so there might be some failures unrelated to your changes. I'll take care of those, if so.

@ezraporter
Copy link
Contributor Author

No problem! I got R CMD check to pass locally so we may be in good shape but you never know :)

@wibeasley
Copy link
Member

wibeasley commented Oct 15, 2022

Looks good, @ezraporter. I'll tweak some things like adding checkmate statements and unit tests.

  1. Will you tell me your ORCiD (eg, Stephan's) for the description file?

  2. What do you mean by these comments? Isn't it ok if someone wants to pass either the fields or the forms, but not both?

    # append forms and fields arrays in format expected by REDCap API
    # If either is NULL nothing will be appended
    post_body <- c(post_body, fields_array, forms_array)

@wibeasley wibeasley self-assigned this Oct 15, 2022
@ezraporter
Copy link
Contributor Author

  1. Will you tell me your ORCiD (eg, Stephan's) for the description file?

This is me: https://orcid.org/0000-0002-4690-8343

  1. What do you mean by these comments? Isn't it ok if someone wants to pass either the fields or the forms, but not both?
    # append forms and fields arrays in format expected by REDCap API
    # If either is NULL nothing will be appended
    post_body <- c(post_body, fields_array, forms_array)

Ah that is a poorly worded comment. The behavior is what you described. Someone can pass either one and the right thing will get into post_body. I was just reminding myself that c(some_object, NULL) yields c(some_object) so this behaves correctly if, for examples, fields_array is NULL.

wibeasley added a commit that referenced this pull request Oct 22, 2022
wibeasley added a commit that referenced this pull request Oct 22, 2022
wibeasley added a commit that referenced this pull request Oct 22, 2022
@wibeasley wibeasley merged commit da7a486 into OuhscBbmc:main Oct 22, 2022
@ezraporter ezraporter deleted the fix-metadata-forms-filter branch December 15, 2022 18:39
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.

Unexpected Behavior: redcap_metadata_read doesn't limit forms when forms parameter is used
2 participants