Red
Section
To start your Phoenix server:
-
mix setup
-
mix phx.server
alias Red.Practice.Card
alias Red.Accounts.User
email = "dewetblomerus@gmail.com"
# email = "dewetblomerus+test@gmail.com"
# email = "dewetblomerus+new@gmail.com"
user = Red.Accounts.User.get_by!(%{email: email})
# dbg(user.id)
# Red.Practice.Attempt.create!(%{
# correct_spelling: "the",
# tried_spelling: "ttt"
# }, actor: user)
# Ash.set_actor(user)
# Ash.get_actor()
# now = DateTime.utc_now()
# [
# %{word: "use", phrase: "use the force, Luke"},
# %{word: "move", phrase: "I like to move it"},
# %{word: "taste", phrase: "Can I taste that chocolate?"},
# %{word: "none", phrase: "We will have none of that"},
# %{word: "sure", phrase: "Are you sure?"},
# %{word: "uses", phrase: "She uses a pencil"},
# %{word: "moved", phrase: "Who moved my cheese?"},
# %{word: "waste", phrase: "Let us not waste food"},
# %{word: "done", phrase: "I am done"},
# %{word: "using", phrase: "I am using a spelling app"},
# %{word: "remove", phrase: "May I remove my shoes?"},
# %{word: "paste", phrase: "Copy and paste"},
# %{word: "used", phrase: "I used a hammer"},
# %{word: "removed", phrase: "She has removed her shoes"},
# ]
# |> Enum.each(fn %{word: word, phrase: phrase} ->
# Red.Practice.Card.create(
# %{
# word: word,
# phrase: phrase
# },
# actor: user
# )
# end)
# Red.Practice.Card.create!(%{
# word: "red"
# }, actor: user)
# Red.Practice.Card
# |> Ash.Query.for_read(:next, %{}, actor: user)
# |> Red.Practice.read_one!()
# card = Red.Practice.Card.next!(actor: user)
# card
# |> Ash.Changeset.for_update(:try, %{tried_spelling: "untried"}, actor: user)
# |> Ash.update!()
# user =
# Red.Accounts.load!(user, [
# :count_cards_reviewed_today,
# :count_cards_goal_today,
# :count_cards_succeeded_today,
# :count_cards_untried,
# :count_cards_practice
# ])
# user.count_cards_reviewed_today
# user.count_cards_succeeded_today
# user.count_cards_practice
# Red.Practice.Card.get_progress_for_list!(actor: user)
# cards =
# Card.for_user!(actor: user)
# tried_cards = Enum.filter(cards, &(!is_nil(&1.retry_at)))
# tried_cards
# |> Enum.map(fn card ->
# DateTime.diff(card.retry_at, card.tried_at, :day)
# end)
require Ash.Query
Red.Practice.Card
|> Ash.Query.filter(interval > 10)
# |> Ash.Query.sort([:title])
|> Red.Practice.read!()