From 1257f295be5ff57659bbe1a909d808ba0b7d11aa Mon Sep 17 00:00:00 2001 From: Eugene Burmakin Date: Fri, 14 Jun 2024 19:33:04 +0200 Subject: [PATCH] Add debugging information to the export service --- .app_version | 2 +- CHANGELOG.md | 5 +++++ app/services/exports/create.rb | 14 +++++++++++--- app/views/exports/index.html.erb | 3 +++ spec/rails_helper.rb | 1 + swagger/v1/swagger.yaml | 2 +- 6 files changed, 22 insertions(+), 5 deletions(-) diff --git a/.app_version b/.app_version index ee6cdce3..b6160487 100644 --- a/.app_version +++ b/.app_version @@ -1 +1 @@ -0.6.1 +0.6.2 diff --git a/CHANGELOG.md b/CHANGELOG.md index d1d36f9e..b7f8aa7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/app/services/exports/create.rb b/app/services/exports/create.rb index 7cfcb6d2..5f62ad6d 100644 --- a/app/services/exports/create.rb +++ b/app/services/exports/create.rb @@ -11,7 +11,12 @@ def initialize(export:, start_at:, end_at:) 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 @@ def call 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 diff --git a/app/views/exports/index.html.erb b/app/views/exports/index.html.erb index a1b1c9b4..c50ed743 100644 --- a/app/views/exports/index.html.erb +++ b/app/views/exports/index.html.erb @@ -25,6 +25,7 @@ Name Status Actions + Created at @@ -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" %> + + <%= export.created_at.strftime('%Y-%m-%d %H:%M:%S') %> <% end %> diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index fb73717f..0bc16e33 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -7,6 +7,7 @@ abort('The Rails environment is running in production mode!') if Rails.env.production? require 'rspec/rails' require 'rswag/specs' +require 'sidekiq/testing' require 'rake' diff --git a/swagger/v1/swagger.yaml b/swagger/v1/swagger.yaml index af7899b9..9fa978fd 100644 --- a/swagger/v1/swagger.yaml +++ b/swagger/v1/swagger.yaml @@ -180,7 +180,7 @@ paths: lat: 52.502397 lon: 13.356718 tid: Swagger - tst: 1718355569 + tst: 1718385215 servers: - url: http://{defaultHost} variables: