Skip to content

Commit

Permalink
getlog: Switch interval to (since; until]
Browse files Browse the repository at this point in the history
  • Loading branch information
syyyr authored and fvacek committed Oct 22, 2024
1 parent fd0a642 commit 6a21aad
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
4 changes: 2 additions & 2 deletions libshvcore/src/utils/getlog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ template <LogReader Type>
continue;
}

if (ctx.params.isSinceLast() || entry.epochMsec < params_since_msec) {
if (ctx.params.isSinceLast() || entry.epochMsec <= params_since_msec) {
logDGetLog() << "\t saving SNAPSHOT entry:" << entry.toRpcValueMap().toCpon();
AbstractShvJournal::addToSnapshot(snapshot, entry);
}
Expand All @@ -181,7 +181,7 @@ template <LogReader Type>
goto exit_nested_loop;
}

if (entry.epochMsec >= params_since_msec && !ctx.params.isSinceLast()) {
if (entry.epochMsec > params_since_msec && !ctx.params.isSinceLast()) {
if ((static_cast<int>(snapshot.keyvals.size()) + record_count + 1) > ctx.params.recordCountLimit) {
log_header.setRecordCountLimitHit(true);
if (last_entry.has_value() && entry.dateTime() != last_entry->dateTime()) {
Expand Down
7 changes: 2 additions & 5 deletions libshvcore/tests/test_getlog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ DOCTEST_TEST_CASE("getLog")
DOCTEST_SUBCASE("since")
{
expected_timestamps = {
"2022-07-07T18:06:17.872Z",
"2022-07-07T18:06:17.874Z",
"2022-07-07T18:06:17.880Z",
};
Expand Down Expand Up @@ -356,7 +355,6 @@ DOCTEST_TEST_CASE("getLog")
{
get_log_params.since = RpcValue::DateTime::fromUtcString("2022-07-07T18:06:17.800");
expected_entries = {
make_entry("2022-07-07T18:06:17.800Z", "value3", 200, false),
make_entry("2022-07-07T18:06:17.950Z", "value2", 10, false),
};
}
Expand Down Expand Up @@ -399,8 +397,7 @@ DOCTEST_TEST_CASE("getLog")
expected_entries = {
make_entry("2022-07-07T18:06:17.800Z", "value1", 0, true),
make_entry("2022-07-07T18:06:17.800Z", "value2", 1, true),
make_entry("2022-07-07T18:06:17.800Z", "value3", 3, true),
make_entry("2022-07-07T18:06:17.800Z", "value3", 200, false),
make_entry("2022-07-07T18:06:17.800Z", "value3", 200, true),
make_entry("2022-07-07T18:06:17.950", "value2", 10, false),
};
}
Expand All @@ -415,7 +412,7 @@ DOCTEST_TEST_CASE("getLog")
expected_entries = {
make_entry("2022-07-07T18:06:17.800Z", "value1", 0, true),
make_entry("2022-07-07T18:06:17.800Z", "value2", 1, true),
make_entry("2022-07-07T18:06:17.800Z", "value3", 3, true),
make_entry("2022-07-07T18:06:17.800Z", "value3", 200, true),
};
}

Expand Down

0 comments on commit 6a21aad

Please sign in to comment.