Skip to content

Commit

Permalink
Fix timestamps in batch writing (#109)
Browse files Browse the repository at this point in the history
* fix timestamps in batch writing

* update CHANGELOG
  • Loading branch information
atimin authored Apr 26, 2024
1 parent a36fcb6 commit cb9af9c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]


## Fixed:

- Timestamps in batch writing, [PR-109](https://github.com/reductstore/reduct-py/pull/109)

## [1.9.0] - 2023-03-08

### Added:
Expand Down
2 changes: 1 addition & 1 deletion reduct/record.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ async def read_all():
last=False,
)

self._records[timestamp] = record
self._records[record.timestamp] = record

def items(self) -> List[Tuple[int, Record]]:
"""Get records as dict items"""
Expand Down
5 changes: 3 additions & 2 deletions tests/bucket_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,10 +424,11 @@ async def read_chunks(rec: Record):
async def test_batched_write(bucket_1):
"""Should write batched records"""
batch = Batch()
# use different timestamp formats
batch.add(1000, b"Hey,", "plain/text", {"label1": "value1"})
batch.add(2000, b"how", "plain/text", {"label2": "value2"})
batch.add(datetime.fromtimestamp(0.002), b"how", "plain/text", {"label2": "value2"})
batch.add(
3000,
datetime.fromtimestamp(0.003).isoformat(),
b"are",
"plain/text",
)
Expand Down

0 comments on commit cb9af9c

Please sign in to comment.