Skip to content

refactor(appengine): use datetimes for data insertion#1129

Merged
Annopaolo merged 2 commits intoastarte-platform:release-1.2from
noaccOS:refactor/datetimes
Mar 17, 2025
Merged

refactor(appengine): use datetimes for data insertion#1129
Annopaolo merged 2 commits intoastarte-platform:release-1.2from
noaccOS:refactor/datetimes

Conversation

@noaccOS
Copy link
Copy Markdown
Collaborator

@noaccOS noaccOS commented Mar 7, 2025

using integer timestamps, especially when doing calculations on them,
is error prone and we've just recently resolved a bug that was caused
by a double "microsecond to millisecond" conversion.

elixir has something more solid than that: DateTimes.

default Ecto types only allow full second or microsecond precision,
but cql timestamps use millisecond precision. To avoid precision errors,
a new Ecto DateTime type has been created, which allows millisecond
precision (althogh no check is made: Xandra handles that itself).

although currently unused, the submillis should now use the correct
number of digits.

an unused and nonfunctioning function in IndividualProperty has been
removed

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes submillis precision probably?

Special notes for your reviewer:

Does this PR introduce a user-facing change?
  • Yes
  • No

Additional documentation e.g. usage docs, diagrams, etc.:


@codecov
Copy link
Copy Markdown

codecov bot commented Mar 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 68.64%. Comparing base (57d2b5b) to head (60b662b).
Report is 7 commits behind head on release-1.2.

Additional details and impacted files
@@               Coverage Diff               @@
##           release-1.2    #1129      +/-   ##
===============================================
- Coverage        68.76%   68.64%   -0.12%     
===============================================
  Files              327      329       +2     
  Lines             7504     7511       +7     
===============================================
- Hits              5160     5156       -4     
- Misses            2344     2355      +11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@noaccOS noaccOS marked this pull request as draft March 7, 2025 16:46
@noaccOS noaccOS force-pushed the refactor/datetimes branch from 4698640 to 6e9f0b2 Compare March 7, 2025 17:53
@noaccOS noaccOS changed the title refactor(appengine): use DateTimes internally refactor(appengine): use datetimes for data insertion Mar 7, 2025
@noaccOS noaccOS force-pushed the refactor/datetimes branch from 6e9f0b2 to a90be74 Compare March 7, 2025 18:05
@noaccOS noaccOS marked this pull request as ready for review March 7, 2025 18:07
@noaccOS noaccOS requested review from Annopaolo, davidebriani, eddbbt and lusergit and removed request for davidebriani and eddbbt March 7, 2025 18:07
@noaccOS noaccOS marked this pull request as draft March 10, 2025 08:36
@noaccOS noaccOS force-pushed the refactor/datetimes branch from a90be74 to 18790f9 Compare March 10, 2025 08:43
@noaccOS noaccOS marked this pull request as ready for review March 10, 2025 08:47
@noaccOS noaccOS force-pushed the refactor/datetimes branch from 18790f9 to 60b662b Compare March 10, 2025 09:38
default Ecto types only allow full second or microsecond precision,
but cql timestamps use millisecond precision. To avoid precision errors,
a new Ecto DateTime type has been created, which allows millisecond
precision (althogh no check is made: Xandra handles that itself).

this change reverts some changes made to the tests in
b27c5a4, restoring the millisecond
precision of the device status

Signed-off-by: Francesco Noacco <francesco.noacco@secomind.com>
@noaccOS noaccOS force-pushed the refactor/datetimes branch from 60b662b to cf14aae Compare March 13, 2025 15:57
using integer timestamps, especially when doing calculations on them,
is error prone and we've just recently resolved a bug that was caused
by a double "microsecond to millisecond" conversion.

elixir has something more solid than that: `DateTime`s.

although currently unused, the submillis should now use the correct
number of digits.

an unused and nonfunctioning function in `IndividualProperty` has been
removed

Signed-off-by: Francesco Noacco <francesco.noacco@secomind.com>
@noaccOS noaccOS force-pushed the refactor/datetimes branch from cf14aae to cc6f174 Compare March 13, 2025 16:01
@noaccOS
Copy link
Copy Markdown
Collaborator Author

noaccOS commented Mar 13, 2025

I've refactored split_submillis to make it more similar to the work done in #1142 after the comments in #1134

@Annopaolo Annopaolo merged commit 6bd720d into astarte-platform:release-1.2 Mar 17, 2025
5 checks passed
@noaccOS noaccOS deleted the refactor/datetimes branch March 17, 2025 14:25
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.

2 participants