core

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package core implements the core models for the leetsolv application.

Index

Constants

View Source
const MaxFamiliarity = int(VeryEasy) + 1
View Source
const MaxImportance = int(CriticalImportance) + 1

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionType

type ActionType string

ActionType defines the type of action performed.

const (
	ActionAdd    ActionType = "add"
	ActionUpdate ActionType = "update"
	ActionDelete ActionType = "delete"
)

func (ActionType) PastTenseString

func (a ActionType) PastTenseString() string

func (ActionType) String

func (a ActionType) String() string

type DefaultRand added in v1.2.0

type DefaultRand struct{}

DefaultRand uses the global math/rand/v2 functions.

func (DefaultRand) IntN added in v1.2.0

func (DefaultRand) IntN(n int) int

type Delta

type Delta struct {
	Action     ActionType `json:"action"`
	QuestionID int        `json:"question_id"`
	OldState   *Question  `json:"old_state"`
	NewState   *Question  `json:"new_state"`
	CreatedAt  time.Time  `json:"created_at"`
}

type Familiarity

type Familiarity int
const (
	VeryHard Familiarity = iota
	Hard
	Medium
	Easy
	VeryEasy
)

type FixedRand added in v1.2.0

type FixedRand struct {
	Value int
}

FixedRand returns a fixed value for deterministic tests.

func (FixedRand) IntN added in v1.2.0

func (f FixedRand) IntN(_ int) int

type Importance

type Importance int
const (
	LowImportance Importance = iota
	MediumImportance
	HighImportance
	CriticalImportance
)

type MemoryUse

type MemoryUse int
const (
	MemoryReasoned MemoryUse = iota
	MemoryPartial
	MemoryFull
)

type ParsedURL added in v1.1.0

type ParsedURL struct {
	Platform      Platform
	NormalizedURL string
	ProblemSlug   string
}

ParsedURL contains normalized URL info from any supported platform

type Platform added in v1.1.0

type Platform string

Platform represents the source platform of a DSA problem

const (
	PlatformLeetCode   Platform = "leetcode"
	PlatformHackerRank Platform = "hackerrank"
)

func (Platform) String added in v1.1.0

func (p Platform) String() string

type Question

type Question struct {
	ID           int         `json:"id"`
	URL          string      `json:"url"`
	Note         string      `json:"note"`
	Familiarity  Familiarity `json:"familiarity"`
	Importance   Importance  `json:"importance"`
	LastReviewed time.Time   `json:"last_reviewed"`
	NextReview   time.Time   `json:"next_review"`
	ReviewCount  int         `json:"review_count"`
	EaseFactor   float64     `json:"ease_factor"`
	UpdatedAt    time.Time   `json:"updated_at"`
	CreatedAt    time.Time   `json:"created_at"`
}

type QuestionMap

type QuestionMap map[int]*Question

type Rand added in v1.2.0

type Rand interface {
	// IntN returns a random int in [0, n).
	IntN(n int) int
}

Rand abstracts random number generation for testability.

type SM2Scheduler

type SM2Scheduler struct {
	Clock clock.Clock
	Rand  Rand
	// contains filtered or unexported fields
}

SM2Scheduler implements the spaced repetition scheduling logic

func NewSM2Scheduler

func NewSM2Scheduler(cfg *config.Config, clock clock.Clock) *SM2Scheduler

func NewSM2SchedulerWithRand added in v1.2.0

func NewSM2SchedulerWithRand(cfg *config.Config, clock clock.Clock, rand Rand) *SM2Scheduler

func (SM2Scheduler) CalculatePriorityScore

func (s SM2Scheduler) CalculatePriorityScore(q *Question) float64

func (SM2Scheduler) Schedule

func (s SM2Scheduler) Schedule(q *Question, memory MemoryUse)

func (SM2Scheduler) ScheduleNewQuestion

func (s SM2Scheduler) ScheduleNewQuestion(q *Question, memory MemoryUse) *Question

type Scheduler

type Scheduler interface {
	ScheduleNewQuestion(q *Question, memory MemoryUse) *Question
	Schedule(q *Question, memory MemoryUse)
	CalculatePriorityScore(q *Question) float64
}

type SearchFilter

type SearchFilter struct {
	Familiarity *Familiarity `json:"familiarity,omitempty"`
	Importance  *Importance  `json:"importance,omitempty"`
	ReviewCount *int         `json:"review_count,omitempty"`
	DueOnly     bool         `json:"due_only,omitempty"`
}

SearchFilter defines filtering criteria for question search

Jump to

Keyboard shortcuts

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