View Source AnkiConnect.Actions.Deck (anki_connect v0.1.1)

Deck actions.

All functions are delegated inside AnkiConnect module, so you should import them from there.

Link to this section Summary

Functions

Moves cards with the given IDs to a different deck, creating the deck if it doesn’t exist yet.

Creates a new configuration group with the given name.

Creates a new empty deck. Will not overwrite a deck that exists with the same name.

Gets the complete list of deck names for the current user.

Gets the complete list of deck names and their respective IDs for the current user.

Deletes decks with the given names.

Gets the configuration group object for the given deck.

Gets statistics such as total cards and cards due for the given decks.

Accepts an array of card IDs and returns an object with each deck name as a key, and its value an array of the given cards which belong to it.

Removes the configuration group with the given ID.

Saves the given configuration group.

Changes the configuration group for the given decks to the one with the given ID.

Link to this section Functions

@spec change_deck(%{cards: [integer()], deck: String.t()}) ::
  {:ok, nil} | {:error, any()}

Moves cards with the given IDs to a different deck, creating the deck if it doesn’t exist yet.

sample-param

Sample param:

%{
  cards: [1502098034045, 1502098034048, 1502298033753],
  deck: "Japanese::JLPT N3"
}

sample-result

Sample result:

{:ok, nil}
Link to this function

clone_deck_config_id(map)

View Source
@spec clone_deck_config_id(%{name: String.t(), clone_from: integer()}) ::
  {:ok, integer()} | {:error, any()}

Creates a new configuration group with the given name.

Clones from the group with the given ID, or from the default group if this is unspecified. Returns the ID of the new configuration group.

sample-param

Sample param:

%{
  name: "Copy of Default",
  clone_from: 1
}

sample-result

Sample result:

{:ok, 1502972374573}
@spec create_deck(%{deck: String.t()}) :: {:ok, nil} | {:error, any()}

Creates a new empty deck. Will not overwrite a deck that exists with the same name.

sample-param

Sample param:

%{
  deck: "Japanese::Tokyo"
}

sample-result

Sample result:

{:ok, nil}
@spec deck_names() :: {:ok, [String.t()]} | {:error, any()}

Gets the complete list of deck names for the current user.

sample-result

Sample result:

{:ok, ["Default"]}
@spec deck_names_and_ids() :: {:ok, map()} | {:error, any()}

Gets the complete list of deck names and their respective IDs for the current user.

sample-result

Sample result:

{:ok, %{"Default" => 1}}
@spec delete_decks(%{decks: [String.t()]}) :: {:ok, nil} | {:error, any()}

Deletes decks with the given names.

Warning: this will not only delete the decks, but also all the cards contained in those decks.

sample-param

Sample param:

%{
  decks: ["Japanese::JLPT N5", "Easy Spanish"],
}

sample-result

Sample result:

{:ok, nil}
@spec get_deck_config(%{deck: String.t()}) :: {:ok, map()} | {:error, any()}

Gets the configuration group object for the given deck.

sample-param

Sample param:

%{
  deck: "Default"
}

sample-result

Sample result:

{:ok, %{
  "lapse" => %{
    "leechFails" => 8,
    "delays" => [10],
    "minInt" => 1,
    "leechAction" => 0,
    "mult" => 0
  },
  "dyn" => false,
  "autoplay" => true,
  "mod" => 1502970872,
  "id" => 1,
  "maxTaken" => 60,
  "new" => %{
    "bury" => true,
    "order" => 1,
    "initialFactor" => 2500,
    "perDay" => 20,
    "delays" => [1, 10],
    "separate" => true,
    "ints" => [1, 4, 7]
  },
  "name" => "Default",
  "rev" => %{
    "bury" => true,
    "ivlFct" => 1,
    "ease4" => 1.3,
    "maxIvl" => 36500,
    "perDay" => 100,
    "minSpace" => 1,
    "fuzz" => 0.05
  },
  "timer" => 0,
  "replayq" => true,
  "usn" => -1
}}
@spec get_deck_stats(%{decks: [String.t()]}) :: {:ok, map()} | {:error, any()}

Gets statistics such as total cards and cards due for the given decks.

sample-param

Sample param:

%{
  decks: ["Japanese::JLPT N5", "Easy Spanish"]
}

sample-result

Sample result:

{:ok, %{
  "1651445861967" => %{
    "deck_id" => 1651445861967,
    "name" => "Japanese::JLPT N5",
    "new_count" => 20,
    "learn_count" => 0,
    "review_count" => 0,
    "total_in_deck" => 1506
  },
  "1651445861960" => %{
      "deck_id" => 1651445861960,
      "name" => "Easy Spanish",
      "new_count" => 26,
      "learn_count" => 10,
      "review_count" => 5,
      "total_in_deck" => 852
  }
}}
@spec get_decks(%{cards: [integer()]}) :: {:ok, map()} | {:error, any()}

Accepts an array of card IDs and returns an object with each deck name as a key, and its value an array of the given cards which belong to it.

sample-param

Sample param:

%{
  cards: [1502298036657, 1502298033753, 1502032366472]
}

sample-result

Sample result:

{:ok, %{
  "Default" => [1502032366472],
  "Japanese::JLPT N3" => [1502298036657, 1502298033753]
}}
Link to this function

remove_deck_config_id(map)

View Source
@spec remove_deck_config_id(%{config_id: integer()}) :: {:ok, nil} | {:error, any()}

Removes the configuration group with the given ID.

sample-param

Sample param:

%{
  config_id: 1502972374573
}

sample-result

Sample result:

{:ok, nil}
Link to this function

save_deck_config(deck_config)

View Source
@spec save_deck_config(%{config: map()}) :: {:ok, nil} | {:error, any()}

Saves the given configuration group.

sample-param

Sample param:

%{
  config: %{
    dyn: false,
    id: 1,
    autoplay: true,
    lapse: %{
      delays: [10],
      leech_action: 0,
      leech_fails: 8,
      minInt: 1,
      mult: 0
    },
    max_taken: 60,
    mod: 1502970872,
    name: "Default",
    new: %{
      bury: true,
      delays: [1, 10],
      initial_factor: 2500,
      ints: [1, 4, 7],
      order: 1,
      per_day: 20,
      separate: true
    },
    rev: %{
      bury: true,
      ease4: 1.3,
      fuzz: 0.05,
      ivlFct: 1,
      max_ivl: 36500,
      min_space: 1,
      per_day: 100
    },
    replayq: true,
    timer: 0,
    usn: -1
  }
}

sample-result

Sample result:

{:ok, nil}
@spec set_deck_config_id(%{decks: [String.t()], config_id: integer()}) ::
  {:ok, nil} | {:error, any()}

Changes the configuration group for the given decks to the one with the given ID.

sample-param

Sample param:

%{
  decks: ["Default"],
  config_id: 1
}

sample-result

Sample result:

{:ok, nil}