From 56e392782ee929ea82f44f457399cedb743720c6 Mon Sep 17 00:00:00 2001 From: Adrian Gruntkowski Date: Thu, 4 Apr 2024 18:13:21 +0200 Subject: [PATCH] Simplify `schedule_job/4` (h/t @RobertJoonas) --- .../google_analytics_controller.ex | 24 ++++++------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/lib/plausible_web/controllers/google_analytics_controller.ex b/lib/plausible_web/controllers/google_analytics_controller.ex index b5b1055a1..3e8e5bcf7 100644 --- a/lib/plausible_web/controllers/google_analytics_controller.ex +++ b/lib/plausible_web/controllers/google_analytics_controller.ex @@ -301,22 +301,12 @@ defmodule PlausibleWeb.GoogleAnalyticsController do end defp schedule_job(site, current_user, property_or_view, opts) do - property? = Google.API.property?(property_or_view) - - importer_fun = - if property? do - &Imported.GoogleAnalytics4.new_import/3 - else - &Imported.UniversalAnalytics.new_import/3 - end - - opts = - if property? do - Keyword.put(opts, :property, property_or_view) - else - Keyword.put(opts, :view_id, property_or_view) - end - - importer_fun.(site, current_user, opts) + if Google.API.property?(property_or_view) do + opts = Keyword.put(opts, :property, property_or_view) + Imported.GoogleAnalytics4.new_import(site, current_user, opts) + else + opts = Keyword.put(opts, :view_id, property_or_view) + Imported.UniversalAnalytics.new_import(site, current_user, opts) + end end end