Skip to content

Improve reading logic for transaction meter values#2038

Merged
goekay merged 1 commit into
masterfrom
improve-transaction-getdetails
May 6, 2026
Merged

Improve reading logic for transaction meter values#2038
goekay merged 1 commit into
masterfrom
improve-transaction-getdetails

Conversation

@goekay

@goekay goekay commented May 6, 2026

Copy link
Copy Markdown
Member
  • Refactor for simplicity: Replace unioned meter value lookups with one explicit query
  • Fix: Keep timestamp fallback to unassigned meter values only
  • Improve nuance: Use half-open zombie transaction cutoff before next transaction start

* Refactor for simplicity: Replace unioned meter value lookups with one explicit query
* Fix: Keep timestamp fallback to unassigned meter values only
* Improve nuance: Use half-open zombie transaction cutoff before next transaction start
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Review Summary by Qodo

Simplify transaction meter value reading with improved zombie transaction handling

✨ Enhancement 🐞 Bug fix

Grey Divider

Walkthroughs

Description
• Refactor meter value query logic from UNION to single explicit query
• Fix timestamp fallback to exclude meter values assigned to other transactions
• Improve zombie transaction cutoff using half-open interval [start, next)
• Add integration test for zombie transaction meter value boundary handling
Diagram
flowchart LR
  A["Transaction Details Query"] --> B["Meter Value Selection"]
  B --> C["Case 1: Transaction ID Match"]
  B --> D["Case 2: Timestamp + Unassigned"]
  C --> E["Combined OR Condition"]
  D --> E
  E --> F["Single Query Result"]
  G["Half-open Interval"] --> H["Start Inclusive"]
  G --> I["Next Start Exclusive"]
  H --> E
  I --> E
Loading

Grey Divider

File Changes

1. src/main/java/de/rwth/idsg/steve/repository/impl/TransactionRepositoryImpl.java ✨ Enhancement +29/-51

Refactor meter value query to single explicit query

• Removed unused imports (ConnectorMeterValueRecord, Field, SelectQuery, Table,
 DATE_TIME_TYPE)
• Replaced UNION-based dual query approach with single explicit query using OR condition
• Changed timestamp condition from inclusive between() to half-open interval using
 greaterOrEqual() and lessThan()
• Added explicit check to exclude meter values assigned to other transactions in timestamp fallback
 case
• Simplified result mapping from positional field access to named getter methods

src/main/java/de/rwth/idsg/steve/repository/impl/TransactionRepositoryImpl.java


2. src/test/java/de/rwth/idsg/steve/repository/impl/TransactionRepositoryImplIT.java 🧪 Tests +48/-0

Add zombie transaction boundary test case

• Added import for CONNECTOR_METER_VALUE table
• Added new integration test
 getDetailsForZombieTransactionDoesNotIncludeNextTransactionStartValue() to verify meter values at
 transaction boundaries
• Added helper method insertTransactionStart() to reduce test code duplication
• Test validates that meter values at next transaction start timestamp are excluded from previous
 transaction

src/test/java/de/rwth/idsg/steve/repository/impl/TransactionRepositoryImplIT.java


Grey Divider

Qodo Logo

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented May 6, 2026

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Qodo Logo

@goekay goekay merged commit 9d3104e into master May 6, 2026
41 checks passed
@goekay goekay deleted the improve-transaction-getdetails branch May 6, 2026 12:54
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