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

Fixed addition of attributes when creating new user #475

Merged
merged 1 commit into from
Jul 12, 2024
Merged

Conversation

this-Aditya
Copy link
Member

When making a POST request to the user endpoint, the user's attributes are not saved, failing the following code from GithubProtocolFetcherStrategy to retrieve user attributes:

Map<String, String> attributes = u.getAttributes() != null ? u.getAttributes() : Map.of();

This approach is effective only when updating an existing user.

Additionally, when setting attributes as shown below:

"attributes": { "arm": "test_audio", "arm": "test_kcl", "arm": "test_health" }

Only the last key-value pair is obtained due to the internal implementation using HashMap, which allows unique keys.

If this behavior is intentional and no updates are necessary, please feel free to close this PR.

Copy link
Member

@yatharthranjan yatharthranjan left a comment

Choose a reason for hiding this comment

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

Nice spot! LGTM, thanks.

Copy link
Member

@mpgxvii mpgxvii left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@this-Aditya
Copy link
Member Author

Additionally, when setting attributes as shown below:

"attributes": { "arm": "test_audio", "arm": "test_kcl", "arm": "test_health" }

Only the last key-value pair is obtained due to the internal implementation using HashMap, which allows unique keys.

Could you please clarify if this behavior is intentional?
Thank you.

@mpgxvii
Copy link
Member

mpgxvii commented Jul 11, 2024

Additionally, when setting attributes as shown below:
"attributes": { "arm": "test_audio", "arm": "test_kcl", "arm": "test_health" }
Only the last key-value pair is obtained due to the internal implementation using HashMap, which allows unique keys.

Could you please clarify if this behavior is intentional? Thank you.

@this-Aditya I think the keys should be unique since the attributes keys from MP would be unique. Did you run into an instance where this is not the case?

@this-Aditya
Copy link
Member Author

To set these attributes when creating a new subject, we are using them to fetch the protocols from RADAR-aRMT-protocols. The attributes for the user are used to navigate to the correct protocol.json file.

Can a user have exactly one protocol? If not, how can we use both protocol.json files (e.g., from both STAGING_PROJECT/arm/test_audio/protocol.json and STAGING_PROJECT/arm/test_health/protocol.json)?

I am not entirely sure about this. Please correct any assumptions I may have wrong.

@yatharthranjan
Copy link
Member

To set these attributes when creating a new subject, we are using them to fetch the protocols from RADAR-aRMT-protocols. The attributes for the user are used to navigate to the correct protocol.json file.

Can a user have exactly one protocol? If not, how can we use both protocol.json files (e.g., from both STAGING_PROJECT/arm/test_audio/protocol.json and STAGING_PROJECT/arm/test_health/protocol.json)?

A user will have only one active protocol, which will be used to schedule the questionnaires. The attribute key has to be unique so the correct protocol can be selected (with the attribute value).
But another user in the same project can have a different attribute value for that key and hence will be on a different protocol; for instance, in a randomised trial with two arms, users in one arm will have protocol 1 and users in second arm will have protocol 2.

@this-Aditya
Copy link
Member Author

Okay, now I understand.
Thanks for the explanation.

@yatharthranjan yatharthranjan merged commit a43ee84 into dev Jul 12, 2024
4 checks passed
@yatharthranjan yatharthranjan deleted the attributes branch July 12, 2024 08:33
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.

3 participants