diff --git a/config/test.exs b/config/test.exs index 67467d7..bae8c17 100644 --- a/config/test.exs +++ b/config/test.exs @@ -8,8 +8,8 @@ config :alkemist, ecto_repos: [Alkemist.Repo] config :alkemist, Alkemist.Repo, adapter: Ecto.Adapters.Postgres, - username: System.get_env("PG_USER"), - password: System.get_env("PG_PASSWORD"), + username: System.get_env("PG_USER") || "postgres", + password: System.get_env("PG_PASSWORD") || "postgres", database: "alkemist_test", hostname: "localhost", pool: Ecto.Adapters.SQL.Sandbox diff --git a/lib/alkemist/assign.ex b/lib/alkemist/assign.ex index 5d5f5ab..3f3ba44 100644 --- a/lib/alkemist/assign.ex +++ b/lib/alkemist/assign.ex @@ -561,11 +561,6 @@ defmodule Alkemist.Assign do {scope, opts, callback} end - defp map_scope({scope, opts}, query, repo), - do: map_scope({scope, opts, fn q -> q end}, query, params, repo) - - defp map_scope(scope, query, repo), do: map_scope({scope, []}, query, params, repo) - # Merges the scope callback into the query defp scope(query, scopes) do current = Enum.find(scopes, fn {_s, opts, _cb} -> opts[:active] == true end) diff --git a/lib/alkemist/controller.ex b/lib/alkemist/controller.ex index 90e9dc4..36e2f87 100644 --- a/lib/alkemist/controller.ex +++ b/lib/alkemist/controller.ex @@ -127,7 +127,7 @@ defmodule Alkemist.Controller do default is `:string`. If the type is `:select`, a collection to build the select must be passed (see `Phoenix.HTMl.Form.select/4`) """ @type filter :: atom() | keyword() - @type field :: atom() | {atom(), map()} | %{title: string(), fields: [{atom(), map()}]} + @type field :: atom() | {atom(), map()} | %{title: String.t(), fields: [{atom(), map()}]} Module.register_attribute __MODULE__, :menu_items, accumulate: true, persist: true diff --git a/lib/alkemist/menu_registry.ex b/lib/alkemist/menu_registry.ex index 9b91123..adbcfbd 100644 --- a/lib/alkemist/menu_registry.ex +++ b/lib/alkemist/menu_registry.ex @@ -91,8 +91,11 @@ defmodule Alkemist.MenuRegistry do end end - defp cache_path(path \\ nil) do - if is_nil(path), do: path = Alkemist.Config.get(:web_interface) + defp cache_path do + cache_path(Alkemist.Config.get(:web_interface)) + end + + defp cache_path(path) do Path.join([System.tmp_dir!(), "#{path}", "alkemist"]) end @@ -160,11 +163,19 @@ defmodule Alkemist.MenuRegistry do defp build_tree([], results), do: results + defp ensure_setup, do: do_ensure_setup(cache_path()) + + defp ensure_setup(module) do + module + |> to_string() + |> app_from_module() + |> cache_path() + |> do_ensure_setup() + end - defp ensure_setup(module \\ nil) do - unless is_nil(module), do: module = app_from_module(to_string(module)) - unless File.exists?(cache_path(module)) do - File.mkdir_p(cache_path(module)) + defp do_ensure_setup(cache_path) do + unless File.exists?(cache_path) do + File.mkdir_p(cache_path) end end end diff --git a/lib/alkemist/query/paginate.ex b/lib/alkemist/query/paginate.ex index 22f6b1c..dffb3e7 100644 --- a/lib/alkemist/query/paginate.ex +++ b/lib/alkemist/query/paginate.ex @@ -15,7 +15,7 @@ defmodule Alkemist.Query.Paginate do """ def run(query, params, opts \\ []) do - query = Turbo.Ecto.paginateq(query, params) + query = Turbo.Ecto.Builder.run(query, params) pagination = Turbo.Ecto.Hooks.Paginate.get_paginate(query, params, opts) {query, pagination} diff --git a/lib/alkemist/query/search.ex b/lib/alkemist/query/search.ex index 3dda801..a157af7 100644 --- a/lib/alkemist/query/search.ex +++ b/lib/alkemist/query/search.ex @@ -7,7 +7,7 @@ defmodule Alkemist.Query.Search do @empty_values [nil, [], {}, [""], "", %{}] def run(query, params) do - searchq(query, params) |> Turbo.Ecto.sortq(params) + searchq(query, params) |> Turbo.Ecto.Builder.run(params) end def searchq(query, params) do @@ -15,11 +15,11 @@ defmodule Alkemist.Query.Search do params |> prepare_params(query) - Turbo.Ecto.searchq(query, params) + Turbo.Ecto.Builder.run(query, params) end def sortq(query, params) do - Turbo.Ecto.sortq(query, params) + Turbo.Ecto.Builder.run(query, params) end @doc """ @@ -27,7 +27,7 @@ defmodule Alkemist.Query.Search do right now this works not on associations """ def prepare_params(params, query) do - queryable = Turbo.Ecto.Utils.schema_from_query(query) + queryable = Turbo.Ecto.Builder.extract_schema(query) search_params = params diff --git a/lib/alkemist/templates/index.html.eex b/lib/alkemist/templates/index.html.eex index d541838..bd6ab5b 100644 --- a/lib/alkemist/templates/index.html.eex +++ b/lib/alkemist/templates/index.html.eex @@ -29,7 +29,7 @@ <%= if any?(@batch_actions) do %>
- <%= form_for @conn, "", [id: "batch-action-form"], fn f -> %> + <%= form_for @conn, "", [id: "batch-action-form"], fn _f -> %> <% end %>