Run this notebook

Use Livebook to open this notebook and explore new ideas.

It is easy to get started, on your machine or the cloud.

Click below to open and run it in your Livebook at .

(or change your Livebook location)

# Red ## Section To start your Phoenix server: - `mix setup` - `mix phx.server` ```elixir 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!() ``` ```elixir # 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 ``` ```elixir # 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!() ```
See source

Have you already installed Livebook?

If you already installed Livebook, you can configure the default Livebook location where you want to open notebooks.
Livebook up Checking status We can't reach this Livebook (but we saved your preference anyway)
Run notebook

Not yet? Install Livebook in just a minute

Livebook is open source, free, and ready to run anywhere.

Run on your machine

with Livebook Desktop

Run in the cloud

on select platforms

To run on Linux, Docker, embedded devices, or Elixir’s Mix, check our README.

PLATINUM SPONSORS
SPONSORS
Code navigation with go to definition of modules and functions Read More ×