Persist listedPrice in offer JSON export#76
Persist listedPrice in offer JSON export#76rl-enjoyer wants to merge 1 commit intoFlipping-Utilities:masterfrom
Conversation
The listedPrice field (the user's GE offer price) was marked transient,
so it was lost on serialization. External tools reading lastOffers from
the JSON export had no way to know the offer price for unfilled slots
(the existing "p" field only records avg fill price, which is 0 when
nothing has filled).
Remove transient and add @SerializedName("lp") so the listed price is
written to disk. Backward compatible — old files without "lp" deserialize
to 0 (same as today), and lastOffers is overwritten on login anyway.
Also add OfferEventSerializationTest with round-trip and backward compat
test cases, and register in TestRunner.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
📝 WalkthroughWalkthroughThe Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/test/java/com/flippingutilities/OfferEventSerializationTest.java (1)
71-71: Use the staticJsonParser.parseString()API on line 71 for consistency with current Gson best practices.The instance method
new JsonParser().parse(json)has been deprecated since Gson 2.8.6 in favor of the staticJsonParser.parseString(json)method.♻️ Proposed update
- JsonObject obj = new JsonParser().parse(json).getAsJsonObject(); + JsonObject obj = JsonParser.parseString(json).getAsJsonObject();🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/test/java/com/flippingutilities/OfferEventSerializationTest.java` at line 71, Replace the deprecated instance usage new JsonParser().parse(json).getAsJsonObject() in OfferEventSerializationTest with the static API JsonParser.parseString(json).getAsJsonObject(): locate the line creating JsonObject obj and change the call to JsonParser.parseString(json) so the test uses the current Gson best-practice static method.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/test/java/com/flippingutilities/OfferEventSerializationTest.java`:
- Line 71: Replace the deprecated instance usage new
JsonParser().parse(json).getAsJsonObject() in OfferEventSerializationTest with
the static API JsonParser.parseString(json).getAsJsonObject(): locate the line
creating JsonObject obj and change the call to JsonParser.parseString(json) so
the test uses the current Gson best-practice static method.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: b88bfeab-d34f-47dd-9171-d1296984ad13
📒 Files selected for processing (3)
src/main/java/com/flippingutilities/model/OfferEvent.javasrc/test/java/com/flippingutilities/OfferEventSerializationTest.javasrc/test/java/com/flippingutilities/TestRunner.java
|
(comment by Claude on behalf of @rl-enjoyer) Good catch on the deprecated |
Summary
transientfromlistedPriceinOfferEventand add@SerializedName("lp")so it's included in the JSON export.pricefield ("p") stores the average fill price, which is 0 when nothing has filled. External tools readinglastOffersfrom the JSON file currently have no way to know what price an unfilled offer is listed at.listedPriceis already populated fromGrandExchangeOffer.getPrice()infromGrandExchangeEvent()and used inSlotPanel.Test
OfferEventSerializationTestwith two cases:listedPrice=136, deserialize, verify it survives"lp"field, verify it defaults to 0TestRunnertransientand adding@SerializedNameBackward compatibility
"lp"deserialize to0(Java int default), same as today.lastOffersentries are overwritten on login when GE slot events fire, so existing users pick up the field automatically.Use case
Building a market scanner tool that reads the plugin's JSON export to give hold/cut advice on open positions. Without the listed price, we can't tell if an unfilled sell offer is priced above market — which is the most common reason a sell isn't filling.
Summary by CodeRabbit
Improvements
Tests