Add debugging information to the export service

This commit is contained in:
Eugene Burmakin 2024-06-14 19:33:04 +02:00
parent 6af4d6d7ef
commit 1257f295be
6 changed files with 22 additions and 5 deletions

View file

@ -1 +1 @@
0.6.1
0.6.2

View file

@ -28,6 +28,11 @@ Please update your `docker-compose.yml` file to include the following changes:
- Fixed a bug where the export file was not being created in the public folder
---
## [0.6.2] — 2024-06-14
This is a debugging release. No changes were made to the application.
---
## [0.6.0] — 2024-06-12

View file

@ -11,7 +11,12 @@ class Exports::Create
def call
export.update!(status: :processing)
points = time_framed_points(start_at, end_at, user)
pp "====Exporting data for #{user.email} from #{start_at} to #{end_at}"
points = time_framed_points
pp "====Exporting #{points.count} points"
data = ::ExportSerializer.new(points, user.email).call
file_path = Rails.root.join('public', 'exports', "#{export.name}.json")
@ -28,7 +33,10 @@ class Exports::Create
attr_reader :user, :export, :start_at, :end_at
def time_framed_points(start_at, end_at, user)
user.tracked_points.without_raw_data.where('timestamp >= ? AND timestamp <= ?', start_at.to_i, end_at.to_i)
def time_framed_points
user
.tracked_points
.without_raw_data
.where('timestamp >= ? AND timestamp <= ?', start_at.to_i, end_at.to_i)
end
end

View file

@ -25,6 +25,7 @@
<th>Name</th>
<th>Status</th>
<th>Actions</th>
<th>Created at</th>
</tr>
</thead>
<tbody>
@ -37,6 +38,8 @@
<%= link_to 'Download', export.url, class: "px-4 py-2 bg-blue-500 text-white rounded-md", download: export.name %>
<% end %>
<%= link_to 'Delete', export, data: { confirm: "Are you sure?", turbo_confirm: "Are you sure?", turbo_method: :delete }, method: :delete, class: "px-4 py-2 bg-red-500 text-white rounded-md" %>
</td>
<td><%= export.created_at.strftime('%Y-%m-%d %H:%M:%S') %></td>
</tr>
<% end %>
</tbody>

View file

@ -7,6 +7,7 @@ require_relative '../config/environment'
abort('The Rails environment is running in production mode!') if Rails.env.production?
require 'rspec/rails'
require 'rswag/specs'
require 'sidekiq/testing'
require 'rake'

View file

@ -180,7 +180,7 @@ paths:
lat: 52.502397
lon: 13.356718
tid: Swagger
tst: 1718355569
tst: 1718385215
servers:
- url: http://{defaultHost}
variables: