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

use predictions v2 and fix bug in decodeRawMessage #550

Merged
merged 4 commits into from
Nov 20, 2024

Conversation

JackVCurtis
Copy link
Contributor

Summary

Ticket: Use predictions v2 channel in Android app

What is this PR for?

Use the same, more scalable endpoint as iOS for the predictions real time data. This PR also fixes a parsing issue with the decodeRawMessage function.

  • If you added any user facing strings on iOS, are they included in Localizable.xcstrings?

Testing

What testing have you done?

@JackVCurtis JackVCurtis requested a review from a team as a code owner November 19, 2024 18:21
Comment on lines -33 to +17
val payloadJson = message.removeRange(message.length - 1, message.length) // remove ']'
val payloadJson = message[4].toString()
Copy link
Member

Choose a reason for hiding this comment

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

I'm nervous about the performance impact of turning this back into a JSON string just so that we can parse it again as JSON a few moments later, but I'm not really sure how straightforward it'd be to avoid that, so it shouldn't have to block this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I don't expect it'll be an issue but I'm digging into Android performance again so I'll keep this in mind as a potential problem. Can always revisit.

}
}
val message = Json.parseToJsonElement(rawMessage).jsonArray
val joinRef = message[0].jsonPrimitive.content
Copy link
Member

Choose a reason for hiding this comment

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

Per the JsonPrimitive.content docs, content will be "null" if the value is null, and contentOrNull is the correct way to get null from null. (The Kotlin serialization library stores JSON internally in a weird half-hydrated state that is optimized specifically for serialization and deserialization more than for in-memory processing, which I learned way too much about as part of FeatureProperties.)

@JackVCurtis JackVCurtis force-pushed the jvc-android-predictions-v2 branch from d2f5a68 to f55ecb0 Compare November 20, 2024 16:54
@JackVCurtis JackVCurtis merged commit 5ae8ab7 into main Nov 20, 2024
5 checks passed
@JackVCurtis JackVCurtis deleted the jvc-android-predictions-v2 branch November 20, 2024 18:03
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.

2 participants