Skip to content

Commit b6c2d2e

Browse files
committed
Implement error message for failed imports
1 parent cf95846 commit b6c2d2e

File tree

18 files changed

+126
-40
lines changed

18 files changed

+126
-40
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ This release adds a dedicated `motion_data` column for transportation-relevant f
2424
- Tracks are exported with their `original_path` serialized as WKT and `track_segments` embedded as a nested array, preserving transportation mode detection data across export/import cycles.
2525
- Digests get a fresh `sharing_uuid` on import for security — old share links from the original user won't work for the importing user.
2626
- Raw Data Archives are exported with their attached gzip files, enabling full data restoration.
27+
- Failed imports now will have an error message shown to the user.
2728

2829
### Changed
2930

@@ -40,6 +41,7 @@ This release adds a dedicated `motion_data` column for transportation-relevant f
4041

4142
- Stats queries (daily distance, time of day) now correctly handle timezone conversion without double-converting from UTC.
4243
- Timezone validation in stats queries now properly resolves Rails timezone names to IANA identifiers.
44+
- Clicking on [Map] on Stats page now correctly respects the user's preferred map version (v1 or v2) instead of always linking to Map v1. #2281
4345

4446

4547
## [1.2.0] - 2026-02-15

app/assets/builds/tailwind.css

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/controllers/imports_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class ImportsController < ApplicationController
1313

1414
def index
1515
@imports = policy_scope(Import)
16-
.select(:id, :name, :source, :created_at, :processed, :status)
16+
.select(:id, :name, :source, :created_at, :processed, :status, :error_message)
1717
.with_attached_file
1818
.order(created_at: :desc)
1919
.page(params[:page])

app/helpers/application_helper.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def trial_button_class(user)
133133

134134
def trial_days_remaining_compact(user)
135135
expiry = user.active_until
136-
return "Expired" if expiry.blank? || expiry.past?
136+
return 'Expired' if expiry.blank? || expiry.past?
137137

138138
days_left = [(expiry.to_date - Time.zone.today).to_i, 0].max
139139
"#{days_left}d left"
@@ -159,11 +159,11 @@ def email_password_login_enabled?
159159
ALLOW_EMAIL_PASSWORD_REGISTRATION
160160
end
161161

162-
def preferred_map_path
163-
return map_v2_path unless user_signed_in?
162+
def preferred_map_path(params = {})
163+
return map_v2_path(params) unless user_signed_in?
164164

165165
preferred_version = current_user.safe_settings.maps&.dig('preferred_version')
166-
preferred_version == 'v1' ? map_v1_path : map_v2_path
166+
preferred_version == 'v1' ? map_v1_path(params) : map_v2_path(params)
167167
end
168168

169169
def format_duration_short(seconds)

app/helpers/stats_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def peak_day(stat)
122122
distance_value = Stat.convert_distance(peak[1], distance_unit).round
123123
text = "#{date.strftime('%B %d')} (#{distance_value} #{distance_unit})"
124124

125-
link_to text, map_url(start_at: date.beginning_of_day, end_at: date.end_of_day), class: 'underline'
125+
link_to text, preferred_map_path(start_at: date.beginning_of_day, end_at: date.end_of_day), class: 'underline'
126126
end
127127

128128
def quietest_week(stat)

app/jobs/stale_jobs_recovery_job.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def recover_stale_exports
3131

3232
def recover_stale_imports
3333
Import.processing.where(processing_started_at: ...IMPORT_TIMEOUT.ago).find_each do |import|
34-
import.update!(status: :failed)
34+
import.update!(status: :failed, error_message: 'Import timed out after being stuck in processing')
3535

3636
Notifications::Create.new(
3737
user: import.user,

app/jobs/users/import_data_job.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ def perform(import_id)
2828
user_id = user&.id || import&.user_id || 'unknown'
2929
ExceptionReporter.call(e, "Import job failed for user #{user_id}")
3030

31+
import&.update!(status: :failed, error_message: e.message)
3132
create_import_failed_notification(user, e)
3233

3334
raise e

app/services/imports/create.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def call
3030
update_import_points_count(import)
3131
User.reset_counters(user.id, :points)
3232
rescue StandardError => e
33-
import.update!(status: :failed)
33+
import.update!(status: :failed, error_message: e.message)
3434
broadcast_status_update
3535

3636
ExceptionReporter.call(e, 'Import failed')

app/services/supporter/verify_email.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def fetch_supporter_status
3333
)
3434

3535
response.success? ? response.parsed_response.symbolize_keys : { supporter: false }
36-
rescue HTTParty::Error, Net::OpenTimeout, Net::ReadTimeout, Errno::ECONNREFUSED, Errno::EHOSTUNREACH, SocketError => e
36+
rescue StandardError => e
3737
Rails.logger.warn("Supporter verification failed: #{e.message}")
3838
{ supporter: false }
3939
end

app/views/imports/_table_row.html.erb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,14 @@
1414
<td data-points-count>
1515
<%= number_with_delimiter import.processed %>
1616
</td>
17-
<td data-status-display><%= import.status %></td>
17+
<td data-status-display>
18+
<%= import.status %>
19+
<% if import.failed? %>
20+
<span class="tooltip tooltip-left cursor-help" data-tip="<%= import.error_message.presence || 'Import failed' %>">
21+
22+
</span>
23+
<% end %>
24+
</td>
1825
<td><%= human_datetime(import.created_at) %></td>
1926
<td class="whitespace-nowrap">
2027
<% if import.deleting? %>

0 commit comments

Comments
 (0)