chore(growth): load is independent from task
Some checks failed
continuous-integration/drone/pr Build is failing
Some checks failed
continuous-integration/drone/pr Build is failing
Ensure that `Growth.Indicators.Load.all/0` can be run independently from the task. So, the `ets` table is create based on the filename processed.
This commit is contained in:
parent
04fff60541
commit
4234b2e917
@ -63,7 +63,7 @@ defmodule Growth.Indicators.Load do
|
|||||||
def all do
|
def all do
|
||||||
"priv/growth/indicators/*.csv"
|
"priv/growth/indicators/*.csv"
|
||||||
|> Path.wildcard()
|
|> Path.wildcard()
|
||||||
|> Enum.map(&create_ets/1)
|
|> Enum.map(&create_ets_from_filename/1)
|
||||||
|> Enum.map(&Task.async(__MODULE__, :load_measure, [&1]))
|
|> Enum.map(&Task.async(__MODULE__, :load_measure, [&1]))
|
||||||
|> Task.await_many()
|
|> Task.await_many()
|
||||||
end
|
end
|
||||||
@ -85,17 +85,18 @@ defmodule Growth.Indicators.Load do
|
|||||||
measure
|
measure
|
||||||
end
|
end
|
||||||
|
|
||||||
@spec filename_to_measure(String.t()) :: {atom(), String.t()}
|
@spec create_ets_from_filename(String.t()) :: {atom(), String.t()}
|
||||||
@doc """
|
@doc """
|
||||||
Translate the given filename to the related module and return both in a tuple.
|
Create ets table based on filename and return a tuple with the ets table name and filename.
|
||||||
"""
|
"""
|
||||||
def filename_to_measure(filename) do
|
def create_ets_from_filename(filename) do
|
||||||
measure =
|
measure =
|
||||||
filename
|
filename
|
||||||
|> Path.basename()
|
|> Path.basename()
|
||||||
|> Path.rootname()
|
|> Path.rootname()
|
||||||
|> String.to_atom()
|
|> String.to_atom()
|
||||||
|> then(&Keyword.get(@measure_to_score, &1, &1))
|
|> then(&Keyword.get(@measure_to_score, &1, &1))
|
||||||
|
|> create_ets()
|
||||||
|
|
||||||
{measure, filename}
|
{measure, filename}
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user