Repository navigation
CSV imports (UI) - #3845
CSV imports (UI)#3845
Conversation
94d52f8 to
a3abbe5
Compare
e25903d to
a05b801
Compare
zoldar
left a comment
There was a problem hiding this comment.
Can you rebase the branch against current master? 🙏
| |> redirect(external: Routes.site_path(conn, :settings_integrations, site.domain)) | ||
| end | ||
|
|
||
| def export(conn, _params) do |
d9cec1e to
c817a13
Compare
|
|
|
Removing
I removed Thank you very much for spotting it! I should've tested browsers other than Safari before committing. |
|
Re 2, are there any errors on the Oban job? Maybe ClickHouse S3 timeout or similar. In that case it probably means you need to set More info:
Hm, but S3 timeout happens after 60s, so maybe it's something else. With S3 timeout, it would also appear to get stuck on a different line, right above |
|
Oban Job kept executing without any errors. I have resolved the issue by swapping "host.docker.internal" for "localhost" in S3 URLs sent to import worker: diff --git a/lib/plausible/imported/csv_importer.ex b/lib/plausible/imported/csv_importer.ex
index 6376d851d..6f6c422ee 100644
--- a/lib/plausible/imported/csv_importer.ex
+++ b/lib/plausible/imported/csv_importer.ex
@@ -65,7 +65,9 @@ defmodule Plausible.Imported.CSVImporter do
"end_date" => end_date
}
+ IO.inspect upload, label: :ABOUT_TO_QUERY
Ch.query!(ch, statement, params, timeout: :infinity)
+ IO.inspect upload, label: :AFTER_QUERY # THIS WAS NEVER SHOWN UNTIL I CHANGED THE HOST
end)
rescue
# we are cancelling on any argument or ClickHouse errors
diff --git a/lib/plausible_web/live/csv_import.ex b/lib/plausible_web/live/csv_import.ex
index 38c97ca17..f538b3e5a 100644
--- a/lib/plausible_web/live/csv_import.ex
+++ b/lib/plausible_web/live/csv_import.ex
@@ -168,6 +168,8 @@ defmodule PlausibleWeb.Live.CSVImport do
%{s3_url: s3_url, presigned_url: upload_url} =
Plausible.S3.import_presign_upload(socket.assigns.site_id, entry.client_name)
+ s3_url = String.replace(s3_url, "localhost", "host.docker.internal")
+
{:ok, %{uploader: "S3", s3_url: s3_url, url: upload_url}, socket}
endAfter the change, the import proceeds basically immediately. In CH logs I can see connection failing with "connection refused" when running the insert query but it surprisingly seems to not propagate back to the client somehow? I'm not sure, I haven't digged too deep into this. |
|
BTW something for a follow-up perhaps but IMHO it would make sense to hide CSV export and import UI when S3 is not configured, at least until local storage version is implemented. WDYT? |
|
When I don't set iex> Plausible.Repo.all Oban.Job
[
%Oban.Job{
__meta__: #Ecto.Schema.Metadata<:loaded, "oban_jobs">,
id: 19,
state: "discarded",
queue: "analytics_imports",
worker: "Plausible.Workers.ImportAnalytics",
args: %{
"end_date" => "2024-01-23",
"import_id" => 10,
"start_date" => "2023-02-09",
"uploads" => [
%{
"filename" => "imported_visitors_20230209_20240123.csv",
"s3_url" => "http://localhost:10000/dev-imports/3/imported_visitors_20230209_20240123.csv"
},
%{
"filename" => "imported_sources_20230209_20240123.csv",
"s3_url" => "http://localhost:10000/dev-imports/3/imported_sources_20230209_20240123.csv"
},
%{
"filename" => "imported_pages_20230209_20240123.csv",
"s3_url" => "http://localhost:10000/dev-imports/3/imported_pages_20230209_20240123.csv"
},
%{
"filename" => "imported_operating_systems_20230209_20240123.csv",
"s3_url" => "http://localhost:10000/dev-imports/3/imported_operating_systems_20230209_20240123.csv"
},
%{
"filename" => "imported_locations_20230209_20240123.csv",
"s3_url" => "http://localhost:10000/dev-imports/3/imported_locations_20230209_20240123.csv"
},
%{
"filename" => "imported_exit_pages_20230209_20240123.csv",
"s3_url" => "http://localhost:10000/dev-imports/3/imported_exit_pages_20230209_20240123.csv"
},
%{
"filename" => "imported_entry_pages_20230209_20240123.csv",
"s3_url" => "http://localhost:10000/dev-imports/3/imported_entry_pages_20230209_20240123.csv"
},
%{
"filename" => "imported_devices_20230209_20240123.csv",
"s3_url" => "http://localhost:10000/dev-imports/3/imported_devices_20230209_20240123.csv"
},
%{
"filename" => "imported_browsers_20230209_20240123.csv",
"s3_url" => "http://localhost:10000/dev-imports/3/imported_browsers_20230209_20240123.csv"
}
]
},
meta: %{},
tags: [],
errors: [
%{
"at" => "2024-03-22T10:11:52.453813Z",
"attempt" => 1,
"error" => "** (Oban.PerformError) Plausible.Workers.ImportAnalytics failed with {:discard, \"Code: 499. DB::Exception: Failed to get object info: Poco::Exception. Code: 1000, e.code() = 111, Connection refused (version 23.3.7.5 (official build)). HTTP response code: 18446744073709551615. (S3_ERROR) (version 23.3.7.5 (official build))\\n\"}"
}
],
attempt: 1,
attempted_by: ["192", "eac88a52-9e1c-4360-af93-b4655763d6a2"],
max_attempts: 3,
priority: 0,
attempted_at: ~U[2024-03-22 10:11:26.687453Z],
cancelled_at: nil,
completed_at: nil,
discarded_at: ~U[2024-03-22 10:11:52.453798Z],
inserted_at: ~U[2024-03-22 10:11:26.652690Z],
scheduled_at: ~U[2024-03-22 10:11:26.652690Z],
conf: nil,
conflict?: false,
replace: nil,
unique: nil,
unsaved_error: nil
}
]I wonder what's different between our setups (I'm running |
|

Changes
This PR adds UI for CSV imports via S3.
screen-recording-2024-03-20-at-183854_Esviayqm.mp4
Tests
Changelog
Documentation
Dark mode