refactor(dup): use DateTime internally#1142
refactor(dup): use DateTime internally#1142noaccOS wants to merge 5 commits intoastarte-platform:release-1.2from
Conversation
9e49bbe to
a948e58
Compare
a948e58 to
df1f304
Compare
c1b32f0 to
522c3b5
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## release-1.2 #1142 +/- ##
===============================================
+ Coverage 63.88% 63.96% +0.07%
===============================================
Files 30 30
Lines 1944 1948 +4
===============================================
+ Hits 1242 1246 +4
Misses 702 702 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
522c3b5 to
5446dba
Compare
Annopaolo
left a comment
There was a problem hiding this comment.
I'm not sure there's a need for using the DecimicrosecondDateTime struct instead of a well-defined separation between integer timestamps and DateTimes, but if it works...
| @groups_lifespan_decimicroseconds 60 * 10 * 1000 * 10000 | ||
| @deletion_refresh_lifespan_decimicroseconds 60 * 10 * 1000 * 10000 | ||
| @datastream_maximum_retention_refresh_lifespan_decimicroseconds 60 * 10 * 1000 * 10000 | ||
| @interface_lifespan minute: 10 |
There was a problem hiding this comment.
This seems rather ad hoc, I'd suggest using the standard :timer.minutes(10) and update DecimicrosecondDateTime.shift consequently.
There was a problem hiding this comment.
It mimics DateTime.shift. Although the duration type is not yet available, we can mimic its functionality if we're just compiling a constant minute: 10 value
There was a problem hiding this comment.
If you don't like, I'd argue for having two variables for each lifespan, as in
@interface_lifespan_amount 10
@interface_lifespan_unit :minute
# usage
DecimicrosecondDateTime.add(datetime, @interface_lifespan_amount, @interface_lifespan_unit)DateTime.add expects a unit anyway, IMO it's easier to understand if we give it in minutes ourselves
There was a problem hiding this comment.
I was not familiar with DateTime.shift's game, now I see why. Looks ok
I started out using a tuple, but ended up using a struct because it allows easier matches here |
|
This has been moved to DataAccess imho it shall not be merged as it is |
import decimicrosecond datetime from astarte-platform/astarte#1142 this way it can be used in data_access's datetime for cast and split_submillis Signed-off-by: Francesco Noacco <francesco.noacco@secomind.com>
|
To be honest, I am not sure what is the problem that the PR is trying to solve. |
5446dba to
ee888e8
Compare
marking as draft as this was made dependent on prs in data_access and core |
ee888e8 to
8bb2a29
Compare
use DateTime.add directly instead of converting to and from timestamps, which makes it harder to understand what's happening Signed-off-by: Francesco Noacco <francesco.noacco@secomind.com>
Signed-off-by: Francesco Noacco <francesco.noacco@secomind.com>
Signed-off-by: Francesco Noacco <francesco.noacco@secomind.com>
Signed-off-by: Francesco Noacco <francesco.noacco@secomind.com>
8bb2a29 to
ffbda9f
Compare
| defp execute_time_based_actions(state, timestamp) do | ||
| if state.connected && state.last_seen_message > 0 do | ||
| if state.connected && DecimicrosecondDateTime.after?(state.last_seen_message, @epoch) do | ||
| # timestamps are handled as microseconds*10, so we need to divide by 10 when saving as a metric for a coherent data |
| alias Astarte.Core.Device, as: CoreDevice | ||
| alias Astarte.Core.InterfaceDescriptor | ||
| alias Astarte.Core.Mapping | ||
| alias Astarte.DataAccess.DateTime, as: MsDateTime |
There was a problem hiding this comment.
we can remove the alias now
| {:astarte_core, github: "noaccOS/astarte_core", branch: "chore/decimicro"}, | ||
| {:astarte_data_access, github: "noaccOS/astarte_data_access", branch: "chore/decimicro"}, |
There was a problem hiding this comment.
check PR description
implement a new type, DecimicrosecondDateTime to allow using DateTimes with one extra precision digit compared to std DateTimes. Functions from the original DateTime are implemented as they're needed. timestamps are preserved in telemetry. Signed-off-by: Francesco Noacco <francesco.noacco@secomind.com>
ffbda9f to
3dce23f
Compare
depends on #1134 to avoid a rebasedepends on astarte-platform/astarte_core#119 and astarte-platform/astarte_data_access#100
see #1129 for context
timestamps are preserved in telemetry.
What this PR does / why we need it:
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g. usage docs, diagrams, etc.: