From 447b13783dd1d52dfd6ce9d6233af9b151c6c8eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Kubern=C3=A1t?= Date: Tue, 22 Oct 2024 09:10:01 +0200 Subject: [PATCH] getlog: Switch interval to (since; until] --- libshvcore/src/utils/getlog.cpp | 4 ++-- libshvcore/tests/test_getlog.cpp | 7 ++----- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/libshvcore/src/utils/getlog.cpp b/libshvcore/src/utils/getlog.cpp index 827bf4d09..45a0dbb29 100644 --- a/libshvcore/src/utils/getlog.cpp +++ b/libshvcore/src/utils/getlog.cpp @@ -171,7 +171,7 @@ template 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); } @@ -181,7 +181,7 @@ template 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(snapshot.keyvals.size()) + record_count + 1) > ctx.params.recordCountLimit) { log_header.setRecordCountLimitHit(true); if (last_entry.has_value() && entry.dateTime() != last_entry->dateTime()) { diff --git a/libshvcore/tests/test_getlog.cpp b/libshvcore/tests/test_getlog.cpp index 18e01b447..37fd4ce24 100644 --- a/libshvcore/tests/test_getlog.cpp +++ b/libshvcore/tests/test_getlog.cpp @@ -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", }; @@ -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), }; } @@ -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), }; } @@ -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), }; }