Skip to content

Persist exact listed price for live GE offers#79

Open
mitchav66 wants to merge 2 commits into
Flipping-Utilities:masterfrom
mitchav66:persist-listed-offer-price
Open

Persist exact listed price for live GE offers#79
mitchav66 wants to merge 2 commits into
Flipping-Utilities:masterfrom
mitchav66:persist-listed-offer-price

Conversation

@mitchav66

@mitchav66 mitchav66 commented Jul 16, 2026

Copy link
Copy Markdown

Summary

  • persist the existing OfferEvent.listedPrice field as compact JSON key lp
  • keep price / p unchanged as the average execution price of filled units
  • preserve compatibility with existing account files, where a missing lp deserializes to 0
  • add serialization coverage for both the new field and old-file fallback

listedPrice is already populated from RuneLite's GrandExchangeOffer.getPrice(). Persisting it allows a restarted client and other local integrations to recover the exact limit price of a live offer, including offers with zero fills, without conflating it with execution price.

Verification

  • gradlew test passes with Temurin JDK 11
  • new tests verify p and lp round-trip independently and old JSON remains readable

Summary by CodeRabbit

  • Bug Fixes

    • Preserved exact listed prices for live offers across application restarts.
    • Recovered unfilled offer prices correctly after restart.
    • Maintained compatibility with older saved data; missing listed prices default to zero.
  • Tests

    • Added coverage to verify listed and pre-tax prices are saved and restored separately.

Updated the comment for listedPrice to clarify its purpose and added the @SerializedName annotation.
@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

OfferEvent.listedPrice is now persisted as the GE limit price under the "lp" JSON key, separately from price. Tests verify round-trip serialization and default deserialization to 0 when legacy data omits the field.

Changes

OfferEvent price persistence

Layer / File(s) Summary
Persist and validate listed price
src/main/java/com/flippingutilities/model/OfferEvent.java, src/test/java/com/flippingutilities/OfferEventSerializationTest.java
listedPrice is persisted as "lp" and documented separately from average execution price; tests verify both fields and legacy inputs missing "lp" default to 0.

Estimated code review effort: 1 (Trivial) | ~5 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: persisting the exact listed price for live GE offers.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/test/java/com/flippingutilities/OfferEventSerializationTest.java (1)

21-23: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Assert JSON values structurally instead of using substring matching.

contains can pass on prefix matches such as "p":910. Parse the JSON object and assert the exact numeric values for p and lp.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/test/java/com/flippingutilities/OfferEventSerializationTest.java` around
lines 21 - 23, Update OfferEventSerializationTest to parse the serialized JSON
into a JSON object before asserting values. Replace substring checks for "p" and
"lp" with structural numeric assertions that require exact values 91 and 94,
preventing prefix matches such as 910.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/test/java/com/flippingutilities/OfferEventSerializationTest.java`:
- Around line 21-23: Update OfferEventSerializationTest to parse the serialized
JSON into a JSON object before asserting values. Replace substring checks for
"p" and "lp" with structural numeric assertions that require exact values 91 and
94, preventing prefix matches such as 910.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a0b6f25b-c168-4d27-a182-b9ff878d0c72

📥 Commits

Reviewing files that changed from the base of the PR and between ea51a0d and da8e085.

📒 Files selected for processing (2)
  • src/main/java/com/flippingutilities/model/OfferEvent.java
  • src/test/java/com/flippingutilities/OfferEventSerializationTest.java

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.

1 participant