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: Get environment from expected function #134

Merged
merged 1 commit into from
May 13, 2024

Conversation

enricocolasante
Copy link
Collaborator

@enricocolasante enricocolasante commented May 13, 2024

TriggerEnvironment is hardcoded to SERVER in rule-engine and this is an issue as it is used to calculate the value of the ProgramRuleVariable #{environment} that can be used in expressions.
This was always an issue between Server and Android but not for Web as rule-engine wasn't a shared library.

Now we need to make it work correctly.

In this PR, I created an expected function to calculate the correct environment that is implemented in all the different platforms Js, Jvm and Native.

We cannot really assume the client from the platform they are using as a server can be implemented in JavaScript and Jvm library can be importer by Android.

Next step could be to have the TriggerEnvironment as an optional value that if not defined will be set to the current environment?

@enricocolasante enricocolasante merged commit 24a80bf into beta May 13, 2024
1 check passed
package org.hisp.dhis.rules

actual fun getEnvironment(): String {
return "ANDROIDCLIENT"
Copy link
Member

Choose a reason for hiding this comment

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

This is not right, the Android client uses the JVM target. Native is for native builds (linux, ios, etc)

@@ -0,0 +1,3 @@
package org.hisp.dhis.rules

expect fun getEnvironment(): String
Copy link
Member

Choose a reason for hiding this comment

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

The return type could directly be TriggerEnvironment to avoid the valueOf methods.

@enricocolasante enricocolasante deleted the env_expected_function branch May 14, 2024 07:04
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