Update imports table

This commit is contained in:
Eugene Burmakin 2025-08-23 16:37:53 +02:00
parent 432e1d2669
commit 5a85a56897
3 changed files with 12 additions and 4 deletions

View file

@ -22,6 +22,7 @@ class Imports::Create
import.source import.source
end end
import.update!(source: source)
importer(source).new(import, user.id, temp_file_path).call importer(source).new(import, user.id, temp_file_path).call
schedule_stats_creating(user.id) schedule_stats_creating(user.id)

View file

@ -36,7 +36,7 @@
</div> </div>
</div> </div>
<div class="overflow-x-auto"> <div class="overflow-x-auto">
<table class="table overflow-x-auto"> <table class="table table-zebra overflow-x-auto">
<thead> <thead>
<tr> <tr>
<th>Name</th> <th>Name</th>
@ -55,7 +55,8 @@
<% @imports.each do |import| %> <% @imports.each do |import| %>
<tr data-import-id="<%= import.id %>" <tr data-import-id="<%= import.id %>"
id="import-<%= import.id %>" id="import-<%= import.id %>"
data-points-total="<%= import.processed %>"> data-points-total="<%= import.processed %>"
class="hover">
<td> <td>
<%= link_to import.name, import, class: 'underline hover:no-underline' %> <%= link_to import.name, import, class: 'underline hover:no-underline' %>
(<%= import.source %>) (<%= import.source %>)
@ -72,9 +73,9 @@
<td><%= human_datetime(import.created_at) %></td> <td><%= human_datetime(import.created_at) %></td>
<td class="whitespace-nowrap"> <td class="whitespace-nowrap">
<% if import.file.present? %> <% if import.file.present? %>
<%= link_to 'Download', rails_blob_path(import.file, disposition: 'attachment'), class: "px-4 py-2 bg-blue-500 text-white rounded-md", download: import.name %> <%= link_to 'Download', rails_blob_path(import.file, disposition: 'attachment'), class: "btn btn-outline btn-sm btn-info", download: import.name %>
<% end %> <% end %>
<%= link_to 'Delete', import, 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" %> <%= link_to 'Delete', import, data: { confirm: "Are you sure?", turbo_confirm: "Are you sure?", turbo_method: :delete }, method: :delete, class: "btn btn-outline btn-sm btn-error" %>
</td> </td>
</tr> </tr>
<% end %> <% end %>

View file

@ -21,6 +21,12 @@ RSpec.describe Imports::Create do
expect(import.reload.status).to eq('processing').or eq('completed') expect(import.reload.status).to eq('processing').or eq('completed')
end end
it 'updates the import source' do
service.call
expect(import.reload.source).to eq('owntracks')
end
context 'when import succeeds' do context 'when import succeeds' do
it 'sets status to completed' do it 'sets status to completed' do
service.call service.call