Skip to content

Commit

Permalink
Add debugging information to the export service
Browse files Browse the repository at this point in the history
  • Loading branch information
Freika committed Jun 14, 2024
1 parent 6af4d6d commit 1257f29
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .app_version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.6.1
0.6.2
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 11 additions & 3 deletions app/services/exports/create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand All @@ -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
3 changes: 3 additions & 0 deletions app/views/exports/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<th>Name</th>
<th>Status</th>
<th>Actions</th>
<th>Created at</th>
</tr>
</thead>
<tbody>
Expand All @@ -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>
Expand Down
1 change: 1 addition & 0 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
2 changes: 1 addition & 1 deletion swagger/v1/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ paths:
lat: 52.502397
lon: 13.356718
tid: Swagger
tst: 1718355569
tst: 1718385215
servers:
- url: http://{defaultHost}
variables:
Expand Down

0 comments on commit 1257f29

Please sign in to comment.