Skip to content

Persist exact listed price for live GE offers - #79

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

Persist exact listed price for live GE offers#79
mitchav66 wants to merge 4 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

    • Persist the exact listed (GE limit) price for live offers instead of treating it as temporary, so it’s retained after restarts.
    • Restore listed prices correctly for unfilled live offers.
    • Maintain backward compatibility with older saved data; when the listed price is missing, it defaults to zero.
  • Tests

    • Added serialization/deserialization tests to verify listed price and execution/pre-tax price are stored under separate JSON keys, including legacy-data behavior.

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

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 38b0cda5-a9e0-4d58-9292-a1acad1fbd06

📥 Commits

Reviewing files that changed from the base of the PR and between a7da818 and b83b289.

📒 Files selected for processing (1)
  • src/test/java/com/flippingutilities/OfferEventSerializationTest.java

📝 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 legacy deserialization defaults.

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 distinct and equal values, round-trip restoration, and legacy inputs missing "lp" defaulting to 0.

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

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: persisting the exact listed price for live GE offers.
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

mitchav66 and others added 2 commits July 22, 2026 13:12
Parse the serialized offer into a JsonObject instead of substring-matching
the raw string. `json.contains("\"lp\":94")` is sensitive to formatting,
cannot distinguish a top-level key from a nested one, and can be satisfied
by a longer key that happens to end in the one under test.

Add the equal-price case, which a substring assertion cannot check at all:
when the listed and execution prices are both 91 there is a single distinct
value in the document, so `contains` passes even if only one of the two keys
was written.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Javadoc on the round-trip and backward-compatibility cases, stating what
each one guarantees rather than restating the assertions.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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