deck

package
v0.0.0-...-e3cadf0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 22, 2024 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package deck provides the model of decks containing flashcards. The user can create, edit and delete decks as well as flashcards from the deck.

Index

Constants

This section is empty.

Variables

View Source
var ErrEmptyFlashcardsSlice = fmt.Errorf("empty flashcards slice")

Functions

This section is empty.

Types

type IService

type IService interface {
	// Storage is embedded to IService for accessing to db methods.
	// temporary solution.
	storage.Storage

	// LoadDecks loads user's decks in memory if needed and returns the decks.
	LoadDecks(ctx context.Context, id models.UserId) (models.Decks, error)

	// NewDeckWithFlashcards creates a new deck and puts all the flashcards there.
	// Returns id of the new deck if there's no error.
	NewDeckWithFlashcards(ctx context.Context, userId models.UserId, cfg models.DeckConfig, flashcards []models.Flashcard) (models.DeckId, error)

	// DeleteDeck deletes the whole deck from user. It doesn't remove flashcards from the deck.
	DeleteDeck(ctx context.Context, userId models.UserId, deckId models.DeckId) error

	// UserMaxBox returns the maximum amount of boxes from the user.
	UserMaxBox(ctx context.Context, uid models.UserId) (models.Box, error)
	Cache() cache.Cache
}

IService is a service for configuration user decks and flashcards.

func NewService

func NewService(
	s storage.Storage,
	c cache.Cache,
	logger *log.Logger,
	creq chan<- *wordmaster.WiktionaryRequest,
) IService

NewService creates a new IService creature.

type Service

type Service struct {
	storage.Storage
	// contains filtered or unexported fields
}

Service is an IService implementation.

func (*Service) Cache

func (s *Service) Cache() cache.Cache

func (*Service) DeleteDeck

func (s *Service) DeleteDeck(ctx context.Context, userId models.UserId, deckId models.DeckId) (err error)

DeleteDeck deletes the whole deck from user. It doesn't remove flashcards from the deck.

func (*Service) LoadDecks

func (s *Service) LoadDecks(ctx context.Context, id models.UserId) (_ models.Decks, err error)

LoadDecks loads user's decks in memory if needed and returns the decks.

func (*Service) NewDeckWithFlashcards

func (s *Service) NewDeckWithFlashcards(ctx context.Context, userId models.UserId, cfg models.DeckConfig, flashcards []models.Flashcard) (_ models.DeckId, err error)

NewDeckWithFlashcards creates a new deck and puts all the flashcards there.

func (*Service) UserMaxBox

func (s *Service) UserMaxBox(ctx context.Context, uid models.UserId) (_ models.Box, err error)

UserMaxBox returns the maximum amount of boxes from the user.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL