Skip to content

CSV exports (UI) - #3875

Merged
zoldar merged 10 commits into
plausible:masterfrom
ruslandoga:csv-exports-ui
Mar 18, 2024
Merged

zoldar merged 10 commits into
plausible:masterfrom
ruslandoga:csv-exports-ui

Conversation

@ruslandoga

@ruslandoga ruslandoga commented Mar 11, 2024 •

Copy link
Copy Markdown
Contributor

Changes

This PR makes the "Export to CSV" button in /:website/settings/imports-exports schedule a Plausible.Workers.ExportCSV job.

Tests

  • Automated tests have been added

Changelog

  • Entry has been added to changelog

Documentation

  • Docs have been updated

Dark mode

  • The UI has been tested both in dark and light mode

@ruslandoga ruslandoga mentioned this pull request Mar 11, 2024
2 of 4 tasks
<PlausibleWeb.Components.Generic.button_link disabled href="">
Export to CSV
</PlausibleWeb.Components.Generic.button_link>
<.form :let={_} for={%{}} action={"/#{@site.domain}/settings/export"}>

@ruslandoga ruslandoga Mar 12, 2024 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just realized that it can probably be a button_link with custom phoenix_html's method attribute set.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's possible to submit "implicit" form with PlausibleWeb.Components.Generic.button too. Example:

<.button
data-to={"/#{URI.encode_www_form(@site.domain)}/settings/forget-import/#{entry.site_import.id}"}
theme="danger"
data-method="delete"
data-csrf={Plug.CSRFProtection.get_csrf_token()}
class="sm:ml-3 sm:w-auto w-full"
data-confirm="Are you sure you want to delete this import?"
>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ruslandoga
ruslandoga requested a review from zoldar March 12, 2024 16:57
@ruslandoga
ruslandoga marked this pull request as ready for review March 12, 2024 16:57
%{site: site, current_user: user} = conn.assigns

Oban.insert!(
Plausible.Workers.ExportCSV.new(%{

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now it exports CSVs without date range in the name like imported_browsers.csv

I'll update it in #3845, or rather, I'll split that PR into two as well, one for business logic and tests and one for UI to make reviewing easier.

@ruslandoga ruslandoga Mar 12, 2024 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason I'm having problems with running this job. It stays in available state for longer than 60 seconds (is this required for job unique-ness?) For the manual test I ran it with

iex> Plausible.Repo.all(Oban.Job) |> List.last |> Plausible.Workers.ExportCSV.perform

Ah, seems like cloud queues are not started in dev env.

Oban.config.queues
[
  rotate_salts: [limit: 1],
  schedule_email_reports: [limit: 1],
  send_email_reports: [limit: 1],
  spike_notifications: [limit: 1],
  check_stats_emails: [limit: 1],
  site_setup_emails: [limit: 1],
  clean_invitations: [limit: 1],
  analytics_imports: [limit: 1],
  domain_change_transition: [limit: 1],
  check_accept_traffic_until: [limit: 1]
]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick-fixed in 17c163c

Comment thread Makefile

minio: ## Start a transient container with a recent version of minio (s3)
docker run -d --rm -p 6000:6000 -p 6001:6001 --name plausible_minio minio/minio server /data --address ":6000" --console-address ":6001"
docker run -d --rm -p 10000:10000 -p 10001:10001 --name plausible_minio minio/minio server /data --address ":10000" --console-address ":10001"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More info on switching from 6000 to 10000 #3845 (comment)

@ruslandoga ruslandoga mentioned this pull request Mar 14, 2024
2 of 4 tasks
)

conn
|> put_flash(:info, "SCHEDULED. WAIT FOR MAIL")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eventually, we could add progress indicator and expose download link on the page too. That's something for later though.

Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>
@zoldar
zoldar merged commit 5e74b1c into plausible:master Mar 18, 2024
@ruslandoga
ruslandoga deleted the csv-exports-ui branch June 10, 2024 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants