Skip to content

Commit

Permalink
refactor(appengine): extract complex queries
Browse files Browse the repository at this point in the history
- create a new module `Data`, which holds complex database operations
- the device_status_from device query has been refactored under DeviceStatus.

Signed-off-by: Francesco Noacco <[email protected]>
  • Loading branch information
noaccOS committed Jan 22, 2025
1 parent 071c297 commit b6f6b3a
Show file tree
Hide file tree
Showing 8 changed files with 1,371 additions and 1,647 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# This file is part of Astarte.
#
# Copyright 2018 Ispirata Srl
# Copyright 2018 - 2025 SECO Mind Srl
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -51,10 +51,15 @@ defmodule Astarte.AppEngine.API.Device.AstarteValue do
end

def to_json_friendly(value, :datetime, opts) do
if opts[:keep_milliseconds] do
value
else
DateTime.from_unix!(value, :millisecond)
cond do
opts[:keep_milliseconds] ->
value

is_integer(value) ->
DateTime.from_unix!(value, :millisecond)

true ->
DateTime.truncate(value, :millisecond)
end
end

Expand Down
Loading

0 comments on commit b6f6b3a

Please sign in to comment.