store

package
v0.1.83 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 16 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package store is api's database: its schema, the migrations that make it, the pool requests take their connections from, and the transaction a write under an account runs in.

Index

Constants

View Source
const (
	GiverOwner   = "owner"
	GiverParent  = "parent"
	GiverLearner = "learner"
)

Who gives a consent: the owner of the account, of their own profile; a parent, by a signed form; or the learner, from the age of digital consent of their country.

View Source
const (
	FormNotSent     = "not_sent"
	FormSent        = "sent"
	FormNotAccepted = "not_accepted"
)

The states of the form of a parent's consent.

View Source
const (
	ConsentBySignedForm = "signed_form"
	ConsentByLearner    = "own_consent"
)

How a consent for a child was checked, as its minimal record keeps it: a parent's by the signed form, the learner's by their own consent.

View Source
const (
	EssayFeedback   = "feedback"
	EssayUnreadable = "unreadable"
	EssayUnchecked  = "unchecked"
	// The marks of a criterion.
	MarkMet         = "met"
	MarkNotMet      = "not_met"
	MarkNotAssessed = "not_assessed"
	// SourceNoFeedback is the phrase "no feedback this time" in place of words
	// that failed a check; the model's words are SourceModel.
	SourceNoFeedback = "no_feedback"
)

How a submission of an essay ends, and the source of its words, as the schema writes them.

View Source
const (
	NothingNotAdmitted   = "not_admitted"
	NothingQuota         = "quota"
	NothingPlatformLimit = "platform_limit"
)

The causes of a choice of nothing to give whose pool the closed AI narrowed.

View Source
const (
	ConsentWaiting   = "waiting"
	ConsentConfirmed = "confirmed"
)

The states of a consent.

View Source
const (
	// SourceModel is the tutor's question, which passed the leak check and the
	// form check.
	SourceModel = "model"
	// SourceFallback is the rung's fallback text.
	SourceFallback = "fallback"
)

The sources of a rung's words, as the schema writes them.

View Source
const (
	// KeyGoing is a request that is still going.
	KeyGoing = "going"
	// KeyDone is a request done, whose answer the record holds.
	KeyDone = "done"
)

The states of a record of an idempotency key.

View Source
const (
	RunPassed      = "passed"
	RunUnchecked   = "unchecked"
	RunNotSuitable = "not_suitable"
	RunAbandoned   = "abandoned"
)

The end reasons of a lesson run, as the schema writes them.

View Source
const (
	WorkHandwriting = "handwriting"
	WorkEssay       = "essay"
	WorkDrawing     = "drawing"
)

The kinds of a stored work, by the attempt's task.

View Source
const AbandonedAfter = 7 * 24 * time.Hour

AbandonedAfter is how long an open attempt goes with no action before it is abandoned: the check of a request closes it then, and so does the daily job.

View Source
const ConsentByOwnerStatement = "owner_statement"

The ways a consent was given. The owner's own is the statement that they are 18 or older, dated with the account.

View Source
const ExportFormat = 5

ExportFormat is the integer of export/VERSION of spec's tag.

View Source
const HintModeShowWhere = "show_where"

HintModeShowWhere is the hint mode of a new profile.

View Source
const ReviewWithin = 3 * 24 * time.Hour

ReviewWithin is the term the operator reviews a problem report in.

View Source
const RunAbandonedAfter = 30 * 24 * time.Hour

RunAbandonedAfter is how long an open lesson run goes with no request on it or its attempts before it is abandoned.

Variables

View Source
var (
	// ErrNotFound is an attempt, a lesson run or an engine's choice that the
	// profile does not have: another profile's is the same.
	ErrNotFound = errors.New("store: the profile has no such row")
	// ErrChoiceBegun is an engine's choice of a task that has begun an attempt
	// already.
	ErrChoiceBegun = errors.New("store: the choice has begun an attempt already")
	// ErrPaper is an attempt of a task from paper, which has no package and no
	// task of a module.
	ErrPaper = errors.New("store: the attempt is of a task from paper")
)

The refusals of the rows of an attempt.

View Source
var (
	// ErrAccountExists is a user who has an account already.
	ErrAccountExists = errors.New("store: the account exists")
	// ErrCodeNotAccepted is a code that is not there, or was redeemed.
	ErrCodeNotAccepted = errors.New("store: the code is not accepted")
)

The refusals of the creation of an account.

View Source
var (
	// ErrProfileExists is a profile there already: the owner's second, or the
	// profile of a consent that has one.
	ErrProfileExists = errors.New("store: the profile exists")
	// ErrNoProfile is a profile that is not the account's.
	ErrNoProfile = errors.New("store: no such profile")
)

The refusals of a profile.

View Source
var (
	// ErrNoAccount is a write under an account that is not there.
	ErrNoAccount = errors.New("store: no account")
	// ErrAccountDeleting is a write under an account marked "deleting".
	ErrAccountDeleting = errors.New("store: the account is being deleted")
)

The refusals of a write under an account.

View Source
var ErrCodeTaken = errors.New("store: the code of the request is taken")

ErrCodeTaken is a code of a request that another waiting consent has: the caller draws another.

View Source
var ErrNoConsent = errors.New("store: no such consent")

ErrNoConsent is a consent for a child that is not the account's.

View Source
var ErrNoForm = errors.New("store: no form of the code waits")

ErrNoForm is a code of a request with no consent that waits for its form to be checked.

View Source
var ErrRecordGone = errors.New("store: the key's record going is gone")

ErrRecordGone is a record going that is no longer there, or no longer this request's, when its request comes to finish: a repeat found it fallen and went again.

View Source
var ErrRunBegun = errors.New("store: the profile has an open run of the lesson")

ErrRunBegun is a lesson run that could not begin because another request began one meanwhile — the profile's open run of the lesson, or the run of the same choice: the request reads it again.

View Source
var ErrStorageOff = errors.New("store: the storage of the profile's works is off")

ErrStorageOff is a work put while the storage of the profile's works is off.

Functions

func AcceptTexts added in v0.1.21

func AcceptTexts(ctx context.Context, tx pgx.Tx, accountID string, texts []TextRef, at time.Time) error

AcceptTexts records the texts the owner accepted with the account, at at.

func AllowCountry added in v0.1.7

func AllowCountry(ctx context.Context, db Querier, country string) (bool, error)

AllowCountry adds country to the list, and says whether it was not there.

func Answers added in v0.1.17

func Answers(ctx context.Context, db pgx.Tx, profileID, attemptID string) ([][]byte, error)

Answers is the answers of the attempt's submissions with a verdict, in order: the ladder finds in them the wrong answer that gave a rung, and its answer slot.

func AppendCorrection added in v0.1.59

func AppendCorrection(ctx context.Context, tx pgx.Tx, profileID, packageDigest, moduleID string, evidence []byte, at time.Time) (int64, error)

AppendCorrection adds an adult's correction of the level of the profile's module to its journal at at, under an ID of its own and the number after the journal's last, and gives the number: evidence, as learner-model's codec gives it, of no attempt, on the package of the module's current version. The caller holds the profile's row of the cache, as for AppendEvidence.

func AppendEvidence added in v0.1.18

func AppendEvidence(ctx context.Context, tx pgx.Tx, profileID string, o Owed, evidence []byte, at time.Time) (int64, error)

AppendEvidence adds the evidence of the profile's attempt to its journal at at, under the number after the journal's last, and gives the number. The caller holds the profile's row of the cache, which orders the numbers.

func AskedQuestions added in v0.1.17

func AskedQuestions(ctx context.Context, db pgx.Tx, profileID, attemptID string) ([]string, error)

AskedQuestions is the tutor's questions on the attempt so far, in order: the words of its rungs that came of a model, which every call of the words gets, so as not to ask them again.

func AsksBeforeShowing added in v0.1.17

func AsksBeforeShowing(ctx context.Context, db Querier, profileID string) (bool, error)

AsksBeforeShowing says whether the profile's setting "ask before showing" is on: a child's, and on by default.

func AttemptOfProfile added in v0.1.21

func AttemptOfProfile(ctx context.Context, db Querier, profileID, attemptID string) (bool, error)

AttemptOfProfile says whether the attempt, open or closed, is the profile's.

func AttemptTask added in v0.1.17

func AttemptTask(ctx context.Context, db Querier, profileID, attemptID string) (digest, taskID string, err error)

AttemptTask is the package and the task of the profile's attempt, read with no lock: what an attempt is of never changes, so a request may choose its way by it before it holds the attempt. One of a task from paper is ErrPaper.

func BeginAttempt added in v0.1.15

func BeginAttempt(ctx context.Context, tx pgx.Tx, profileID string, a NewAttempt, at time.Time) (string, error)

BeginAttempt begins a at at, in tx, once the profile's open attempt is closed: the profile has one open attempt of a module. A choice that has begun an attempt already is ErrChoiceBegun.

func BeginLessonRun added in v0.1.17

func BeginLessonRun(ctx context.Context, tx pgx.Tx, profileID string, r NewRun, at time.Time) (string, error)

BeginLessonRun begins the run r at at, in tx, and gives its ID. A profile that has an open run of the lesson already is ErrRunBegun, and tx can go on: the insert runs in a savepoint of its own.

func BeginPaperAttempts added in v0.1.72

func BeginPaperAttempts(ctx context.Context, tx pgx.Tx, profileID, pageID string, n int, at time.Time) ([]string, error)

BeginPaperAttempts closes "left", at at, in tx, the profile's open attempts of tasks from paper of another page than pageID, and begins n attempts of tasks from paper on it, one of each, their IDs in order. An attempt of paper gives no evidence, so the close settles none. Its caller holds the account's row FOR NO KEY UPDATE (HoldAccount), so that two beginnings of one profile go one after the other and the second sees the first's attempts.

func CancelChildConsent added in v0.1.21

func CancelChildConsent(ctx context.Context, tx pgx.Tx, accountID, consentID string) (bool, error)

CancelChildConsent takes back the account's consent for a child with no profile, and says whether there was one: one that waits is erased, with its form; one confirmed leaves its minimal record and its form for their term. Neither counts toward the limit after.

func CanonicalID added in v0.1.7

func CanonicalID(id string) bool

CanonicalID says whether id is a UUID as the database writes one: lowercase, with its dashes. Any other ID names no row, and nothing is asked of it: OpenFGA would refuse the colons of urn:uuid:, and hold no tuple of an uppercase one.

func ChoiceBegun added in v0.1.15

func ChoiceBegun(ctx context.Context, db Querier, profileID, choiceID string) (bool, error)

ChoiceBegun says whether the engine's choice has begun an attempt.

func ClearAccount added in v0.1.8

func ClearAccount(ctx context.Context, tx pgx.Tx, accountID string) error

ClearAccount deletes, in the transaction that marked the account "deleting", all the database keeps of it but its ID, its UID and the time of the mark: every profile as DeleteProfileRows deletes one, the consents that wait and the adults', the records of its keys, its counters of the quota, the texts it was made on, its fields, the binding of its invite code — the code stays redeemed — and of its problem reports, which stay to their term.

func CloseAbandonedAttempts added in v0.1.14

func CloseAbandonedAttempts(ctx context.Context, db Querier, before, at time.Time) (int64, error)

CloseAbandonedAttempts closes "abandoned", at at, the open attempts with no action since before, a batch at a time, and says how many it closed. One clock judges the term and dates the close: the pass's. An attempt a request holds is skipped, and the next pass finds it if it is still idle; the term is checked again on the row the UPDATE takes, so an action that came meanwhile keeps the attempt open. The close moves no date of the profile's activity.

func CloseAttempt added in v0.1.15

func CloseAttempt(ctx context.Context, tx pgx.Tx, profileID, attemptID, reason string, at time.Time) error

CloseAttempt closes the open attempt with reason at at; one closed already keeps its close.

func ClosePlatformAI added in v0.1.23

func ClosePlatformAI(ctx context.Context, q Querier, now time.Time) (bool, error)

ClosePlatformAI sets the flag "platform AI closed" at now, and says whether this call set it: one set already keeps its time.

func ConnectModule added in v0.1.13

func ConnectModule(ctx context.Context, db Querier, profileID, moduleID string) error

ConnectModule connects the module to the profile, now; a module connected already keeps the time it was connected. A profile that is gone is ErrNoProfile: the row refers to it.

func Countries added in v0.1.7

func Countries(ctx context.Context, db Lister) ([]string, error)

Countries is the list, by code.

func CountryAccepted added in v0.1.7

func CountryAccepted(ctx context.Context, db Querier, country string) (bool, error)

CountryAccepted says whether the deployment takes learners from country. None is taken until the operator adds it.

func CreateAccount added in v0.1.5

func CreateAccount(ctx context.Context, db Beginner, uid string, codeSHA256 []byte, texts []TextRef) (string, error)

CreateAccount creates the account of the sign-in service's UID by the code of codeSHA256, with the owner's statement that they are 18 or older dated now, and returns its ID. It is one transaction, in the order of the contract: an account the UID has already is ErrAccountExists — or ErrAccountDeleting, when it is marked — before the code is looked at, so that a repeat is not refused for the code it redeemed; then a code not there or redeemed is ErrCodeNotAccepted, and no account is left. The code is bound to the account, and its tariff passes to it, and the texts the owner accepted are recorded with it.

Two creations race safely. Two by one UID: the second waits on the UID's unique index and finds the first's account. Two for one code: the second waits on the code's row and finds it redeemed. Either way, a first one that rolls back leaves the second to go on.

func CreateInvite added in v0.1.5

func CreateInvite(ctx context.Context, db Querier, codeSHA256 []byte, tariff string) error

CreateInvite keeps a new invite code by its SHA-256 alone, with the tariff it passes to the account that redeems it.

func DeleteAccountRow added in v0.1.8

func DeleteAccountRow(ctx context.Context, db Beginner, accountID string) error

DeleteAccountRow is the last step of the deletion of an account: in one transaction, it clears again what a row written late may have left, and deletes the account's row. An account that is not there is deleted already.

func DeleteProfileRows added in v0.1.8

func DeleteProfileRows(ctx context.Context, tx pgx.Tx, profileID string) error

DeleteProfileRows deletes, in the transaction that holds the profile, all that the database keeps of it: its consent — for a child into its minimal record, an adult's whole — its records of idempotency keys, and the profile. Every other row of a profile goes with it by its keys.

func DeleteWork added in v0.1.39

func DeleteWork(ctx context.Context, db Querier, profileID, attemptID string) error

DeleteWork erases the profile's stored work of the attempt, when one is kept.

func DisconnectModule added in v0.1.13

func DisconnectModule(ctx context.Context, db Querier, profileID, moduleID string) error

DisconnectModule disconnects the module from the profile; a module not connected changes nothing.

func DropConsentRecords added in v0.1.11

func DropConsentRecords(ctx context.Context, db Querier, before time.Time) (int64, error)

DropConsentRecords deletes the minimal records of consents for children whose account or profile was deleted before before, a batch at a time, and says how many went: a record is kept 5 years after the deletion and then erased. A stop between batches keeps what went.

func DropForm added in v0.1.21

func DropForm(ctx context.Context, db Querier, object string) error

DropForm deletes the row of a scan the store erased, unless its consent took it back meanwhile.

func DropKeys added in v0.1.9

func DropKeys(ctx context.Context, db Querier, before time.Time) (int64, error)

DropKeys deletes the records of idempotency keys made before before, a batch at a time, and says how many went: a key is kept for a day. A stop between batches keeps what went.

func DropQuotaCounters added in v0.1.23

func DropQuotaCounters(ctx context.Context, db Querier, before time.Time) (int64, error)

DropQuotaCounters deletes the counters of the quota whose day ended before before, of the profiles and of the accounts, a batch at a time, and says how many it deleted: a counter is needed for its day and for a day after it, to settle the requests that went over midnight.

func DropRecord added in v0.1.17

func DropRecord(ctx context.Context, tx pgx.Tx, accountID, key string, made time.Time) error

DropRecord deletes the account's record going made at made — of a request refused after its call, which records nothing — or, with made zero, whichever is going: of a request that fell, which a repeat runs again.

func DropReports added in v0.1.21

func DropReports(ctx context.Context, db Querier, before time.Time) (int64, error)

DropReports deletes the reports reviewed before before, a batch at a time.

func EndAbandonedRuns added in v0.1.14

func EndAbandonedRuns(ctx context.Context, db Querier, before, at time.Time) (int64, error)

EndAbandonedRuns ends "abandoned", at at, the open lesson runs with no action since before, a batch at a time, as CloseAbandonedAttempts closes attempts: no request on the run, and no action on its attempts, which is the run's too.

func EndLessonRun added in v0.1.17

func EndLessonRun(ctx context.Context, tx pgx.Tx, profileID, runID, reason string, at time.Time) error

EndLessonRun ends the profile's open run with reason at at; one ended already keeps its end. A run that ends "not suitable" closes its open attempt "not suitable" with it.

func EndedSegments added in v0.1.17

func EndedSegments(ctx context.Context, tx pgx.Tx, profileID, runID string) ([]int, error)

EndedSegments is the places of the run's task segments that have ended, in order: those whose attempt was closed by a correct answer, by the solution shown or by "Done".

func ExplainRung added in v0.1.17

func ExplainRung(ctx context.Context, tx pgx.Tx, profileID, attemptID string, rung int, read, other Words, at time.Time) error

ExplainRung records, at at, that "explain differently" was asked for on the attempt's rung, and the words that came of it. A rung whose words never came is recorded with read, the words the learner read before: its fallback text.

func ExportAccount added in v0.1.21

func ExportAccount(ctx context.Context, tx pgx.Tx, accountID string) (exportv5.Account, error)

ExportAccount is the account's part of the export: its fields that are no secret and every consent of it, in full, and the IDs of its profiles.

func FamilyDay added in v0.1.23

func FamilyDay(ctx context.Context, tx pgx.Tx, accountID string, reported *int32, now time.Time) (quota.Day, error)

FamilyDay is the account's family day at now, once a request on platform AI sent the offset reported, if any: the offset, when valid, kept for the days to come, and the day that holds now, kept once the day before is over. It writes in tx, which holds the account's row already, as a request under a key does (HoldAccount), and only what changed. The offset is no field of any line of the log.

func FinishRecord added in v0.1.17

func FinishRecord(ctx context.Context, tx pgx.Tx, accountID, key string, made time.Time, target KeyTarget) error

FinishRecord turns the account's record going, the one made at made, into done with its target, in the transaction of what the request writes after its call.

func FormsPastTerm added in v0.1.21

func FormsPastTerm(ctx context.Context, db Lister, today time.Time, after string, limit int) ([]string, error)

FormsPastTerm is up to limit objects of scans whose consent is gone and whose term ended by today, the day by UTC, in the order of their names after after.

func GiveCorrectWords added in v0.1.46

func GiveCorrectWords(ctx context.Context, tx pgx.Tx, profileID, attemptID string) error

GiveCorrectWords records that the tutor's words after a correct answer were given on the attempt, which a correct answer closed: once.

func GiveOwnConsent added in v0.1.21

func GiveOwnConsent(ctx context.Context, tx pgx.Tx, profileID string, textVersion *int32) (bool, error)

GiveOwnConsent confirms the learner's own consent of the profile, which waits, to the version of teen-consent, and says whether it waited.

func GiveRequested added in v0.1.17

func GiveRequested(ctx context.Context, tx pgx.Tx, profileID, attemptID string, techniques, leading bool, at time.Time) error

GiveRequested records, at at, that a hint asked for gave the techniques of the attempt's task, when techniques — it has some —, and its leading question, when leading, each the first time it did, and that the attempt's last action is at.

func GiveStepTechniques added in v0.1.15

func GiveStepTechniques(ctx context.Context, tx pgx.Tx, profileID, attemptID string, at time.Time) error

GiveStepTechniques records that the techniques of the attempt's task were given at a step, the first time they were, and that the attempt's last action is at.

func HasOwnerProfile added in v0.1.7

func HasOwnerProfile(ctx context.Context, tx pgx.Tx, accountID string) (bool, error)

HasOwnerProfile says whether the account has the owner's profile.

func HaveAccounts added in v0.1.9

func HaveAccounts(ctx context.Context, db Lister, uids []string) (map[string]bool, error)

HaveAccounts is the UIDs, of uids, that have an account, marked or not: the daily job removes the users of the sign-in service that have none.

func HeldMapSkill added in v0.1.19

func HeldMapSkill(ctx context.Context, db Querier, profileID string) (string, error)

HeldMapSkill is the skill chosen on the skill map that the profile's last choice holds, empty when it holds none: a choice from the map holds until the learner asks for something else.

func HoldAccount added in v0.1.7

func HoldAccount(ctx context.Context, tx pgx.Tx, accountID string) error

HoldAccount takes the account's row FOR NO KEY UPDATE in tx: what a request under an idempotency key holds first, so that a repeat beside it waits and finds its record. The lock conflicts with itself and not with FOR KEY SHARE, so the other writes under the account do not wait for it.

func HoldAttemptRun added in v0.1.17

func HoldAttemptRun(ctx context.Context, tx pgx.Tx, profileID, attemptID string) error

HoldAttemptRun holds FOR UPDATE, in tx, the lesson run of the profile's attempt, when it is one of a run, or of the profile's open attempt when attemptID is empty: a request on an attempt holds its run first, as the requests on the run do, so that the close of the attempt, which may end the run, takes the two rows in the order every request takes them.

func HoldKeyChecks added in v0.1.47

func HoldKeyChecks(ctx context.Context, tx pgx.Tx, accountID string) ([]time.Time, error)

HoldKeyChecks takes the account's row FOR NO KEY UPDATE and reads when each check of an own key it keeps was made, in the order they were counted; it may hold checks older than the window, which no longer count. The lock conflicts with itself and not with FOR KEY SHARE: the checks of one account — from two devices, or two tabs — are counted one after the other, and none is lost, while the other writes under the account do not wait for them.

func HoldPin added in v0.1.6

func HoldPin(ctx context.Context, tx pgx.Tx, accountID string) (pin.State, error)

HoldPin takes the account's row FOR NO KEY UPDATE and reads its PIN. The lock conflicts with itself and not with FOR KEY SHARE: the requests of the PIN of one account — from two devices, or a repeat beside its first — go one after the other, and its count loses no wrong PIN, while the other writes under the account do not wait for them.

func HoldProfile added in v0.1.43

func HoldProfile(ctx context.Context, tx pgx.Tx, accountID, profileID string) error

HoldProfile holds the account's profile FOR NO KEY UPDATE in tx, or is ErrNoProfile: what a write takes before the profile's consent, so that it holds the two rows in the order of the deletion of a profile, which takes the profile FOR UPDATE and reaches the consent by the cascade, and the two wait rather than deadlock. NO KEY UPDATE is the lock an UPDATE of the row takes anyway, and it lets a row that references the profile be written.

func JournalModules added in v0.1.18

func JournalModules(ctx context.Context, tx pgx.Tx, profileID string) ([]string, error)

JournalModules is the modules of the profile's journal, by ID.

func JudgeForm added in v0.1.21

func JudgeForm(ctx context.Context, db Querier, code string, accept bool) error

JudgeForm confirms, when accept, the parent's consent of the code, which waits with its form sent, as checked by its signed form; otherwise it marks the form not accepted, and the adult sends a new one. A code of no such consent is ErrNoForm.

func KeepPaperCheck added in v0.1.80

func KeepPaperCheck(ctx context.Context, tx pgx.Tx, profileID, attemptID string, check, turn []byte) error

KeepPaperCheck keeps check, the message Check of novatrail.paper.v1, on the profile's open attempt of a task from paper in place of the Check before, until the attempt closes. turn is what the history keeps of the Check before, nil when there was none, and goes to its end; the rungs the learner was shown of the ladder before go, so that each rung of the new ladder is given anew. An attempt that is not of paper, or closed, keeps none.

func KeptWorkKind added in v0.1.39

func KeptWorkKind(ctx context.Context, db Querier, profileID, attemptID string) (string, error)

KeptWorkKind is the kind of the profile's stored work of the attempt, or ErrNotFound when none is kept.

func LastAttempt added in v0.1.17

func LastAttempt(ctx context.Context, db Querier, profileID, attemptID string) (bool, error)

LastAttempt says whether the attempt is the last the profile began of its kind: the words after a correct answer are given while the profile has begun no other, and an attempt of a module and the attempts of a page go beside each other.

func LastSubmission added in v0.1.15

func LastSubmission(ctx context.Context, db Querier, profileID, attemptID string) ([]byte, bool, error)

LastSubmission is the answer of the attempt's last submission with a verdict, and whether it has one.

func MarkDeleting

func MarkDeleting(ctx context.Context, tx pgx.Tx, accountID string) error

MarkDeleting takes the account's row FOR UPDATE in tx and marks it "deleting", the first step of the deletion of an account. FOR UPDATE is what waits for every write that holds the row by FOR KEY SHARE: a plain UPDATE of the mark takes FOR NO KEY UPDATE, which does not conflict with FOR KEY SHARE, and would let a write that does not touch the row commit after the mark. The deletion clears the account's data in the same tx, after this.

func MarkIdle added in v0.1.9

func MarkIdle(ctx context.Context, tx pgx.Tx, accountID string, before time.Time) (bool, error)

MarkIdle marks the account "deleting" in tx, as MarkDeleting does, only if it still had no request since before, and says whether it did. The term is read under the row's lock: a request that wrote today's date while the job chose the account keeps it, since FOR UPDATE waits for that write and reads the row again (П-9).

func Migrate

func Migrate(ctx context.Context, url string) (applied int, version int64, err error)

Migrate applies to the database at url every migration of api it has not had, and returns how many it applied and the version the schema is at.

func MigrateFiles added in v0.1.2

func MigrateFiles(ctx context.Context, url string, files fs.FS) (applied int, version int64, err error)

MigrateFiles applies the migrations in files — api's, or OpenFGA's for the rights — to the database at url that it has not had. url is the direct connection: goose holds an advisory lock of the session while it migrates, so that two runs never migrate at once, and Neon's pooler keeps no session. Each migration runs in a transaction of its own, but one its file says may not.

func ModuleConnected added in v0.1.15

func ModuleConnected(ctx context.Context, db Querier, profileID, moduleID string) (bool, error)

ModuleConnected says whether the module is connected to the profile.

func NoteModel added in v0.1.83

func NoteModel(ctx context.Context, tx pgx.Tx, accountID, key string, made time.Time, model, models int) error

NoteModel writes into the account's record going made at made the place of the model that now reads its request's work, from 0, and the length of the call's list: what CheckProgress gives while the request goes on. A record no longer going, or no longer this request's, is left as it is.

func Open

func Open(ctx context.Context, url string) (*pgxpool.Pool, error)

Open is a pool of connections to the database at url. The pool takes them as it needs them, and pgx keeps its prepared statements by the protocol, which Neon's pooler keeps too.

func OpenPlatformAI added in v0.1.23

func OpenPlatformAI(ctx context.Context, q Querier) (bool, error)

OpenPlatformAI clears the flag "platform AI closed", and says whether it was set: the operator's command, once the provider's limit is lifted.

func PaperWordsOf added in v0.1.72

func PaperWordsOf(ctx context.Context, db Querier, profileID string) (language string, showWhere bool, err error)

PaperWordsOf is what the tutor's words of a task from paper read of the profile: the language of its interface, "" when it has none, and whether its hint mode is "Show where".

func PendForm added in v0.1.21

func PendForm(ctx context.Context, db Querier, object, mediaType string, at time.Time) error

PendForm records the object a scan is about to go to, before it goes: a row of no consent, erased by the daily job today, so that a scan whose request failed after it went is erased too, and none lies in the store unknown to the database.

func PlatformAIClosed added in v0.1.23

func PlatformAIClosed(ctx context.Context, q Querier) (bool, error)

PlatformAIClosed says whether the flag "platform AI closed" of the deployment is set: read on every request that would call platform AI, so that one set by any instance, or cleared by the operator, holds at once on all.

func ProfileGrade added in v0.1.18

func ProfileGrade(ctx context.Context, db Querier, profileID string) (*int, error)

ProfileGrade is the profile's school grade, nil when it names none.

func ProfileIdle added in v0.1.9

func ProfileIdle(ctx context.Context, tx pgx.Tx, accountID, profileID string, before time.Time) (bool, error)

ProfileIdle holds the account's profile FOR UPDATE in tx if it was still active last before before, and says whether it was: a request that touched it today while the job chose it keeps it (П-9).

func ProfileOf added in v0.1.4

func ProfileOf(ctx context.Context, db Querier, accountID, profileID string) (bool, time.Time, error)

ProfileOf says whether the account has the profile, and the date of the profile's last activity. It is read after the right to the profile, never before: a tuple whose profile is gone — dangling — gives a right to nothing.

func ProfilesOwingEvidence added in v0.1.18

func ProfilesOwingEvidence(ctx context.Context, db Lister, digests []string, after string, n int) ([]string, error)

ProfilesOwingEvidence is up to n of the profiles with an attempt that owes its evidence, on the packages digests names, by ID after the ID after, for the daily job.

func ProfilesThere added in v0.1.9

func ProfilesThere(ctx context.Context, db Lister, ids []string) (map[string]string, error)

ProfilesThere is the profiles, of ids, that are there, each with its account: a tuple whose profile is not, or is another account's, is dangling. An ID that is no UUID as the database writes one names no row, and is not asked.

func PutWork added in v0.1.39

func PutWork(ctx context.Context, tx pgx.Tx, accountID, profileID string, w Work) error

PutWork keeps w in tx, in the place of the work kept of its attempt before, while the storage of the profile's works is on: ErrStorageOff when it is off, ErrNoProfile when the account has no such profile, ErrNotFound when the attempt is not the profile's. The profile's row is held FOR SHARE, which a switch of the storage off waits for and waits on — SetWorkStorage at its HoldProfile, before the consent, and SwitchWorkStorageOff at its UPDATE in any case: a work put before the switch is erased by it, and one after it is refused. FOR KEY SHARE would not do: both take FOR NO KEY UPDATE, which does not conflict with it.

func QuotaFits added in v0.1.23

func QuotaFits(ctx context.Context, q Querier, c Charge) (quota.Spent, error)

QuotaFits says whether the charge c would fit, reserving nothing: what is left of the day holds a typical task, at the beginning of an attempt.

func RecordDone added in v0.1.6

func RecordDone(ctx context.Context, tx pgx.Tx, accountID, key, method, fingerprint string, target KeyTarget) error

RecordDone records a request done under the account's key, with its target, in the transaction of the action, so that the action and its record commit together or not at all. A request on the account itself names no profile.

func RecordGoing added in v0.1.17

func RecordGoing(ctx context.Context, tx pgx.Tx, accountID, key, method, fingerprint string, target KeyTarget) (time.Time, error)

RecordGoing records a request under the account's key as going, with what it acts on, and commits with the checks before its call of AI: a repeat beside it is "still going" until it is done, or until it outlives the longest a request may run. It gives when the record was made, by the database's clock: the mark by which the request finishes or drops its own record, and never a repeat's that took its place.

func RemoveCountry added in v0.1.7

func RemoveCountry(ctx context.Context, db Querier, country string) (bool, error)

RemoveCountry takes country off the list, and says whether it was there. The profiles of the country stay: a new one is refused.

func ReserveQuota added in v0.1.23

func ReserveQuota(ctx context.Context, tx pgx.Tx, c Charge) (quota.Spent, error)

ReserveQuota reserves the charge c on the counters of the profile and of the account of its day, in tx, when it fits beside what each has spent and holds in reserve, and says why it does not when it does not, writing nothing. The counters of a day are made by its first reserve. tx holds the account's row already, as a request under a key does, so that two reserves of one account — two devices, a profile and its owner — go one after the other, and the counters are held besides against a settlement going on.

func RestateAge added in v0.1.21

func RestateAge(ctx context.Context, tx pgx.Tx, c Consent, r Restated) error

RestateAge writes the age given again of the profile c is the consent of, held: its category, country and the day the age was given, today; and, when r names a new giver, a new consent in the place of c, which waits. A code another waiting consent has is ErrCodeTaken, in a savepoint of its own, and the caller asks again with c: what was done before it holds.

func ReviewReport added in v0.1.21

func ReviewReport(ctx context.Context, db Querier, reportID string) error

ReviewReport marks the report reviewed now, which starts its year; a report not there, or reviewed already, is ErrNotFound.

func RunLesson added in v0.1.17

func RunLesson(ctx context.Context, db Querier, profileID, runID string) (string, error)

RunLesson is the full ID of the lesson of the profile's run, read with no lock: what a run is of never changes.

func SendForm added in v0.1.21

func SendForm(ctx context.Context, tx pgx.Tx, c Consent, object string) error

SendForm makes the scan at object, pended, the form of the consent c, a parent's that waits, held, and the form sent; the scan it sent before is no longer its form, and goes today.

func SetDebugModels added in v0.1.74

func SetDebugModels(ctx context.Context, db Querier, uid string, right bool) error

SetDebugModels gives the account of the sign-in service's UID the right of the debug mode, or takes it. An account marked "deleting", whose fields are cleared, is none — ErrNoAccount, as is a UID with no account.

func SetPaperReading added in v0.1.74

func SetPaperReading(ctx context.Context, tx pgx.Tx, profileID, attemptID string, reading []byte) error

SetPaperReading keeps the reading of the statement of the profile's open attempt of a task from paper, the message Reading of novatrail.paper.v1, until the attempt closes. An attempt that is not of paper, or closed, keeps none.

func SetTariff added in v0.1.23

func SetTariff(ctx context.Context, db Querier, codeSHA256 []byte, tariff string) error

SetTariff gives the account that redeemed the code of codeSHA256 the tariff: one statement finds the account by the code it is bound to, and an account marked "deleting", whose code is unbound already or soon, is none — ErrNoAccount, as is a code that no account redeemed. The code keeps the tariff it was made with: it passes on only when redeemed, which it is already.

func SettleQuota added in v0.1.23

func SettleQuota(ctx context.Context, db Beginner, c Charge, spent quota.Micro) error

SettleQuota settles the reserve of the charge c, on the day of its reserve, by what the call cost: the reserve leaves the counters of the profile and of the account, and spent is added to what each has spent, in one transaction of its own on db. A counter gone meanwhile — the profile deleted, the account — is no failure: there is nothing left to settle.

func ShownRungs added in v0.1.80

func ShownRungs(ctx context.Context, db pgx.Tx, profileID, attemptID string) ([]string, error)

ShownRungs is the words the learner was shown on the attempt's rungs, in order, whatever they came of: each rung's words, and the words "explain differently" gave it after them.

func SubmissionAnswer added in v0.1.15

func SubmissionAnswer(ctx context.Context, db Querier, profileID, submissionID string) ([]byte, error)

SubmissionAnswer is the answer of the profile's submission by its ID.

func Submit added in v0.1.15

func Submit(ctx context.Context, tx pgx.Tx, profileID, attemptID string, answer, observation []byte, wrong bool, at time.Time) (string, error)

Submit records a submission with a verdict of the attempt, by its answer and the observation of its work, as the attempt's next, and counts it a wrong answer when wrong: the attempt's last action is at. It gives the submission's ID.

func SubmitEssay added in v0.1.49

func SubmitEssay(ctx context.Context, tx pgx.Tx, profileID, attemptID string, answer []byte, e Essay, at time.Time) (string, error)

SubmitEssay records a submission of an essay of the attempt, by its answer — without the text read and the words of the feedback — and how it ended, as the attempt's next, whose last action is at. It gives the submission's ID.

func Submitted added in v0.1.49

func Submitted(ctx context.Context, db Querier, profileID, attemptID string) (bool, error)

Submitted says whether the profile's attempt has a submission, however it ended: what "Done" asks of an attempt with a rubric.

func SwitchWorkStorageOff added in v0.1.21

func SwitchWorkStorageOff(ctx context.Context, tx pgx.Tx, profileID string, at time.Time) error

SwitchWorkStorageOff switches the storage of the profile's works off at at, records when, and erases every work the server keeps of the profile, in tx: one step. The works go after the profile's row is updated, which waits for a PutWork holding it FOR SHARE, unless tx waited for it before, at HoldProfile: the DELETE then sees the work that PutWork kept. In the other order the DELETE would lock the rows that PutWork waits to update while the UPDATE waits for PutWork.

func SwitchWorkStorageOn added in v0.1.21

func SwitchWorkStorageOn(ctx context.Context, tx pgx.Tx, profileID, giver string, textVersion *int32, at time.Time) error

SwitchWorkStorageOn switches the storage of the profile's works on at at, by the consent of giver to the version of storage-consent: a record of its own, in the place of an open one of another giver.

func Today added in v0.1.23

func Today(ctx context.Context, q Querier, accountID string, now time.Time) (quota.Day, error)

Today is the account's family day at now as it keeps it, writing nothing: for a request that sends no offset, such as the beginning of an attempt.

func TodayByUTC added in v0.1.7

func TodayByUTC(on, now time.Time) bool

TodayByUTC says whether on is the date of now by UTC: the date written once a day, of an account or a profile, that needs no writing again.

func TouchAccount added in v0.1.4

func TouchAccount(ctx context.Context, db Querier, accountID string) error

TouchAccount writes today, by UTC, as the date of the account's last request, once a day at most: the date the account is deleted by after 12 months with no request. A plain UPDATE takes FOR NO KEY UPDATE, which the writes under the account, by FOR KEY SHARE, do not wait for.

func TouchLessonRun added in v0.1.17

func TouchLessonRun(ctx context.Context, tx pgx.Tx, profileID, runID string, at time.Time) error

TouchLessonRun records a request on the profile's open run at at: its last action. A request on an attempt of the run is its attempt's action, which the run's last action reads too.

func TouchProfile added in v0.1.7

func TouchProfile(ctx context.Context, db Querier, profileID string) error

TouchProfile writes today, by UTC, as the date of the profile's last activity, once a day at most: the date a profile is deleted by after 12 months with none (П-9), as TouchAccount writes the account's.

func WaitingConsents added in v0.1.11

func WaitingConsents(ctx context.Context, tx pgx.Tx, accountID string) (int, error)

WaitingConsents is how many consents for a child wait under the account with no profile: those the limit of CAUSE_TOO_MANY_CONSENTS counts. It takes no lock: its caller holds the account's row FOR NO KEY UPDATE, by HoldAccount, as every request under a key does, so that two requests beside each other count one after the other.

func WorkDecider added in v0.1.39

func WorkDecider(ctx context.Context, db Querier, accountID, profileID string) (string, error)

WorkDecider is who gave the consent of the account's profile, and so decides the storage of its works, read without a lock, or ErrNoProfile: a profile has a consent always. A lock on the consent would wait in another order than the deletion of the profile, which holds the profile first.

func WorkStorageOn added in v0.1.21

func WorkStorageOn(ctx context.Context, tx pgx.Tx, profileID string) (giver string, on bool, err error)

WorkStorageOn is the open record of the storage of the profile's works: who gave its consent, and whether it is on.

func WriteChoice added in v0.1.19

func WriteChoice(ctx context.Context, tx pgx.Tx, profileID string, c NewChoice, at time.Time) (string, error)

WriteChoice writes the profile's choice c, made at at, and gives its ID.

func WriteKeyChecks added in v0.1.47

func WriteKeyChecks(ctx context.Context, tx pgx.Tx, accountID string, checked []time.Time) error

WriteKeyChecks writes when each check of an own key the account keeps was made, after HoldKeyChecks held its row.

func WritePin added in v0.1.6

func WritePin(ctx context.Context, tx pgx.Tx, accountID string, state pin.State) error

WritePin writes the account's PIN as state has it: after an action that left one set, which every action of the PIN does.

func WriteProfile added in v0.1.7

func WriteProfile(ctx context.Context, tx pgx.Tx, p Profile) error

WriteProfile writes the settings of p, the profile ProfileFor held: what an adult changes, and nothing the profile was created with.

func WriteReport added in v0.1.21

func WriteReport(ctx context.Context, tx pgx.Tx, accountID, profileID string, r Report) (string, error)

WriteReport records the report of the account's profile, at its CreatedAt, and gives its ID.

func WriteRung added in v0.1.17

func WriteRung(ctx context.Context, tx pgx.Tx, profileID, attemptID string, rung int, w Words) error

WriteRung records the words of the attempt's rung, the first that came for it.

func WriteSkillState added in v0.1.18

func WriteSkillState(ctx context.Context, tx pgx.Tx, profileID string, s SkillState) error

WriteSkillState writes the profile's cache: its state, the mark it was computed on and the number of the last evidence it holds.

func WriteUnderAccount

func WriteUnderAccount(ctx context.Context, db Beginner, accountID string, fn func(pgx.Tx) error) error

WriteUnderAccount runs fn in a transaction that holds the account's row by FOR KEY SHARE and has found it not marked "deleting". The deletion of an account takes the row FOR UPDATE, so a write that got here before the mark commits before the mark is set, and one after it sees the mark and writes nothing. FOR KEY SHARE, rather than FOR SHARE, lets fn itself update fields of the row — the date of the request, the PIN's count — without locking out a neighbouring request of the same account. The transaction commits when fn returns nil, and rolls back on its error, which it returns as it is.

Types

type Account added in v0.1.4

type Account struct {
	// ID is the account's own ID, the subject of the rights.
	ID string
	// Deleting says the account is marked "deleting".
	Deleting bool
	// LastRequestOn is the date, by UTC, of the account's last request; zero if
	// none was written yet.
	LastRequestOn time.Time
	// DebugModels says the account has the right of the debug mode.
	DebugModels bool
}

Account is what a request knows of the account of its token.

func AccountByUID added in v0.1.4

func AccountByUID(ctx context.Context, db Querier, uid string) (Account, error)

AccountByUID is the account of the sign-in service's UID, or ErrNoAccount.

func (Account) TouchedOn added in v0.1.4

func (a Account) TouchedOn(now time.Time) bool

TouchedOn says whether the date of the last request is already the date of now by UTC, so that TouchAccount would write nothing.

type AccountRef added in v0.1.9

type AccountRef struct {
	ID  string
	UID string
}

AccountRef is an account the daily job works on: its ID and its UID at the sign-in service.

func IdleAccounts added in v0.1.9

func IdleAccounts(ctx context.Context, db Lister, before time.Time, after string, limit int) ([]AccountRef, error)

IdleAccounts is up to limit accounts not marked whose last request was before before, whose ID comes after after, by ID: those the daily job deletes after 12 months without a request (П-9). An account with no date of a request yet is none of them.

func MarkedBefore added in v0.1.9

func MarkedBefore(ctx context.Context, db Lister, before time.Time, after string, limit int) ([]AccountRef, error)

MarkedBefore is up to limit accounts marked "deleting" before before, whose ID comes after after — empty for the first page —, by ID: the marks a request left unfinished, which the daily job finishes. The job pages by the last ID it saw, so that an account it fails on is not chosen again in the same pass.

type Attempt added in v0.1.15

type Attempt struct {
	ID             string
	Paper          bool
	PackageDigest  string
	ModuleID       string
	ModuleVersion  string
	FormatVersion  string
	ModuleKit      string
	TaskID         string
	Seed           uint64
	Instance       *int
	ChoiceID       *string
	LessonRunID    *string
	Segment        *int
	PreviousID     *string
	LastActionAt   time.Time
	CloseReason    *string
	WrongAnswers   int
	StepTechniques bool
	// RequestedTechniques and LeadingQuestion say whether a hint asked for gave
	// the task's techniques, and its leading question.
	RequestedTechniques bool
	LeadingQuestion     bool
	// CorrectWordsGiven says whether the tutor's words after a correct answer were
	// given on it.
	CorrectWordsGiven bool
	// PaperCheck is the last Check of an attempt of a task from paper, the
	// message Check of novatrail.paper.v1, while the attempt is open: nil before
	// its first Check.
	PaperCheck []byte
	// PaperHistory is the Checks of an attempt of a task from paper before its
	// last, in order, while it is open: each a message Check of its verdicts, its
	// tutor's words and, in its hints, the rungs of its ladder the learner was
	// shown.
	PaperHistory [][]byte
	// PaperReading is the reading of the statement of an attempt of a task from
	// paper, the message Reading of novatrail.paper.v1, while the attempt is open:
	// nil before "Recognise" made it.
	PaperReading []byte
}

Attempt is an attempt's row, as the requests on it read it. One of a task from paper has Paper, and the fields of a module, its package, its task and its seed empty.

func HoldAttempt added in v0.1.15

func HoldAttempt(ctx context.Context, tx pgx.Tx, profileID, attemptID string) (Attempt, error)

HoldAttempt is the profile's attempt by its ID, its row held FOR UPDATE in tx, so that the requests on one attempt go one after the other; ErrNotFound when the profile has none.

func HoldOpenAttempt added in v0.1.15

func HoldOpenAttempt(ctx context.Context, tx pgx.Tx, profileID string) (Attempt, bool, error)

HoldOpenAttempt is the profile's open attempt of a task of a module, its row held FOR UPDATE in tx, and whether it has one: the open attempts of a page from paper stay beside it.

type Beginner

type Beginner interface {
	Begin(ctx context.Context) (pgx.Tx, error)
}

Beginner is what a transaction starts from: a pool, or a connection.

type Charge added in v0.1.23

type Charge struct {
	AccountID, ProfileID string
	Day                  quota.Day
	Amount               quota.Micro
	// OffDeployment says api runs off a deployment, where alone a tariff of the
	// dev projects has its caps (quota.CapsOf): unset, it has none.
	OffDeployment bool
}

Charge is what a request takes of the quota of platform AI: of the profile and its account, on the family day of its reserve, the amount reserved.

type ChildConsent added in v0.1.5

type ChildConsent struct {
	ID          string
	AgeCategory string
	Country     string
	// State is "waiting" or "confirmed".
	State string
	// Giver is who gives it: GiverOwner, GiverParent or GiverLearner.
	Giver string
	// RequestCode and FormState are a parent's: the code of the request and the
	// state of the form.
	RequestCode string
	FormState   string
	// Applied is the age of digital consent of the country on the day the age was
	// given, by which the category was; 0 for the owner's.
	Applied int
}

ChildConsent is a consent for a child that waits for its profile.

func AskChildConsent added in v0.1.21

func AskChildConsent(ctx context.Context, tx pgx.Tx, accountID string, c NewConsent) (ChildConsent, error)

AskChildConsent records a consent for a child that waits, under the account: with no pseudonym, no other field of the profile, and not the age in years. A code of a request another waiting consent has is ErrCodeTaken, and tx can go on: the insert runs in a savepoint of its own.

type Choice added in v0.1.15

type Choice struct {
	Kind     string
	ModuleID string
	TaskID   string
	LessonID string
}

Choice is what an engine's choice names, as far as the beginning of an attempt or a lesson run reads it: its kind, its module, and the task of a choice of a task or the lesson's local ID of a choice of a lesson.

func ChoiceOf added in v0.1.15

func ChoiceOf(ctx context.Context, db Querier, profileID, choiceID string) (Choice, error)

ChoiceOf is the profile's engine's choice by its ID, or ErrNotFound.

type ClosedAttempt added in v0.1.19

type ClosedAttempt struct {
	ID            string
	PackageDigest string
	ModuleID      string
	TaskID        string
	CloseReason   string
	ClosedAt      time.Time
	LessonID      *string
	ReasonCode    *int
	Evidence      []byte
}

ClosedAttempt is a closed attempt of the profile as the engine's input reads it: what it was of, how and when it closed, the full ID of the lesson of its run, the reason code of the choice that began it — of its run's, for a segment; none for an attempt begun again or by a choice with no reason code —, and its evidence, when the journal has it.

func ClosedAttempts added in v0.1.19

func ClosedAttempts(ctx context.Context, db Lister, profileID string) ([]ClosedAttempt, error)

ClosedAttempts is the profile's closed attempts of modules, the last closed first.

type ConnectedModule added in v0.1.13

type ConnectedModule struct {
	ModuleID    string
	ConnectedAt time.Time
}

ConnectedModule is a module connected to a profile: its ID and when it was connected, with no version.

func ConnectedModules added in v0.1.13

func ConnectedModules(ctx context.Context, db Lister, profileID string) ([]ConnectedModule, error)

ConnectedModules is the modules connected to the profile, in the order they were connected, and by ID among those connected at one time.

type Consent struct {
	ChildConsent
	// ProfileID is the profile created by it, or empty while there is none.
	ProfileID string
}

Consent is a consent for a child, as its profile is created by it.

func ConsentFor added in v0.1.7

func ConsentFor(ctx context.Context, tx pgx.Tx, accountID, consentID string) (Consent, error)

ConsentFor is the account's consent for a child, held FOR UPDATE in tx, or ErrNoConsent.

func ConsentOfProfile added in v0.1.21

func ConsentOfProfile(ctx context.Context, tx pgx.Tx, accountID, profileID string) (Consent, error)

ConsentOfProfile is the consent of the account's profile, held FOR UPDATE in tx, or ErrNoConsent.

type Correction added in v0.1.59

type Correction struct {
	ModuleID string
	Evidence []byte
}

Correction is a correction of a module's level in a profile's journal: the module and the evidence, as learner-model's codec gives it.

func Corrections added in v0.1.59

func Corrections(ctx context.Context, db Lister, profileID, module string) ([]Correction, error)

Corrections is the corrections of the level of the module of the profile's journal, or with module empty of every module, connected or not since, in the order of the modules' IDs byte by byte and of the journal.

type Cursor added in v0.1.18

type Cursor struct {
	StartedAt time.Time
	ID        string
}

Cursor is where a page of the progress goes on from: the attempt last on the page before, by its beginning and its ID.

type Entry added in v0.1.18

type Entry struct {
	Seq           int64
	AttemptID     string
	PackageDigest string
	ModuleID      string
	ClosedAt      time.Time
	Evidence      []byte
}

Entry is a row of a profile's journal of evidence: its number, its attempt, the package and the module of the attempt, when the attempt closed, and the evidence as learner-model's codec gives it. A row of an adult's correction of a module's level has no attempt, AttemptID empty and ClosedAt zero, and its package is that of the module's current version when the level was set.

func Journal added in v0.1.18

func Journal(ctx context.Context, db Lister, profileID string, after int64) ([]Entry, error)

Journal is the profile's journal of evidence after the number after, in order.

type Essay added in v0.1.49

type Essay struct {
	End    string
	Marks  []string
	Source *string
}

Essay is how a submission of an essay ended: its end, and beside feedback the mark of each criterion by its number in the rubric, from 1, and the source of the words. Neither the text read nor the words are in it.

type EssaySubmission added in v0.1.49

type EssaySubmission struct {
	AttemptID   string
	SubmittedAt time.Time
	Essay
}

EssaySubmission is a submission of an essay as the server keeps it: when it came, and how it ended.

func EssaySubmissions added in v0.1.49

func EssaySubmissions(ctx context.Context, db Lister, profileID string, attemptIDs []string) ([]EssaySubmission, error)

EssaySubmissions is the submissions of the profile's attempts of attemptIDs that are essays, by attempt and in order.

type ExportedAttempt added in v0.1.21

type ExportedAttempt struct {
	exportv5.Attempt
	Owed Owed
	// LeadingQuestionGiven says the task's leading question was given on
	// request, which its package words.
	LeadingQuestionGiven bool
}

ExportedAttempt is an attempt as the export reads it, with the rows the package of its module turns into what it tells: its task, its instance and the bytes of the answers of its submissions.

type ExportedPaperAttempt added in v0.1.72

type ExportedPaperAttempt struct {
	Attempt exportv5.PaperAttempt
	Answers [][]byte
}

ExportedPaperAttempt is an open attempt of a task from paper as the export reads it, with the bytes of the answers of its submissions. The Check it keeps, with the model's hidden solution and answer, never reaches the device, and the export reads none of it.

type ExportedProfile added in v0.1.21

type ExportedProfile struct {
	Profile       exportv5.Profile
	Attempts      []ExportedAttempt
	PaperAttempts []ExportedPaperAttempt
	Evidence      [][]byte
	State         []byte
	Observations  map[string]map[int64][]byte
}

ExportedProfile is a profile's part of the export as the database holds it, with the bytes of its records of protobuf: each piece of evidence, by the order of the log, the state, and each submission's observation, by the attempt and the number of the submission. The stored works it names in the profile alone, without their bytes.

func ExportProfile added in v0.1.21

func ExportProfile(ctx context.Context, tx pgx.Tx, accountID, profileID string) (ExportedProfile, error)

ExportProfile is the profile's part of the export, of the account's profile, or ErrNoProfile.

type Issued added in v0.1.19

type Issued struct {
	Skill string
	At    time.Time
}

Issued is when a skill was last handed out by a choice, by its full ID.

func IssuedSkills added in v0.1.19

func IssuedSkills(ctx context.Context, db Lister, profileID string) ([]Issued, error)

IssuedSkills is when each skill the profile's choices handed out was last handed out: a lesson hands out each of its skills.

type KeyRecord added in v0.1.6

type KeyRecord struct {
	Method       string
	Fingerprint  string
	State        string
	Response     []byte
	SubmissionID string
	// Age is how long ago the record was made, by the database's clock: a record
	// still going past the longest a request may run is of a request that fell.
	Age time.Duration
}

KeyRecord is what is recorded of a request under its idempotency key: its method, its fingerprint, its state and, once done, its answer — or, for an answer that holds what the learner sent, the submission it recorded.

func RecordOf added in v0.1.6

func RecordOf(ctx context.Context, tx pgx.Tx, accountID, key string) (KeyRecord, bool, error)

RecordOf is the record of the account's key, and whether there is one.

type KeyTarget added in v0.1.15

type KeyTarget struct {
	ProfileID    string
	AttemptID    string
	SubmissionID string
	Response     []byte
}

KeyTarget is what a request done under a key acted on, and what its record holds of the answer: the profile and the attempt it acted on, when it did, and either the answer or the submission whose answer a repeat gets.

type Learner added in v0.1.13

type Learner struct {
	AgeCategory string
	Consented   bool
	// Country and Applied are the country of the learner and the age of digital
	// consent their category was given by, by which their age may be asked again.
	Country string
	Applied int
}

Learner is what a learning request reads of its profile, in one query: the age category, by which a module's audience suits it, and whether its consent is confirmed: a profile has one consent at most, which a learner who consents themselves, or whose age was given again, waits for.

func LearnerOf added in v0.1.13

func LearnerOf(ctx context.Context, db Querier, accountID, profileID string) (Learner, error)

LearnerOf is the learner of the account's profile; ErrNoProfile when the account has no such profile.

type LessonRun added in v0.1.17

type LessonRun struct {
	ID            string
	LessonID      string
	ModuleID      string
	ModuleVersion string
	PackageDigest string
	ChoiceID      string
	LastActionAt  time.Time
	EndReason     *string
}

LessonRun is a lesson run's row, as the requests on it read it.

func HoldLessonRun added in v0.1.17

func HoldLessonRun(ctx context.Context, tx pgx.Tx, profileID, runID string) (LessonRun, error)

HoldLessonRun is the profile's lesson run by its ID, its row held FOR UPDATE in tx, so that the requests on one run go one after the other; ErrNotFound when the profile has none.

func OpenRunOf added in v0.1.17

func OpenRunOf(ctx context.Context, tx pgx.Tx, profileID, lessonID string) (LessonRun, bool, error)

OpenRunOf is the profile's open run of the lesson, by its full ID, held, and whether it has one.

func RunOfChoice added in v0.1.17

func RunOfChoice(ctx context.Context, tx pgx.Tx, profileID, choiceID string) (LessonRun, bool, error)

RunOfChoice is the run the profile's engine's choice opened, held, and whether it opened one.

type Lister added in v0.1.7

type Lister interface {
	Query(ctx context.Context, sql string, args ...any) (pgx.Rows, error)
}

Lister is what a list is read from: a pool, a connection or a transaction.

type MadeChoice added in v0.1.19

type MadeChoice struct {
	ID          string
	Kind        string
	NotAdmitted bool
	Closed      string
	NextDay     *time.Time
}

MadeChoice is a choice written: its ID and kind, and, beside nothing to give, whether its answer said the AI was closed — and why, by a word of NothingCauses, with when the next family day begins beside the quota.

func ChoiceAfterAttempt added in v0.1.19

func ChoiceAfterAttempt(ctx context.Context, db Querier, profileID, attemptID string) (MadeChoice, bool, error)

ChoiceAfterAttempt is the choice the close of the profile's attempt gave as what comes next, and whether it gave one: a repeat of the request that closed it gives it again.

func ChoiceAfterRun added in v0.1.19

func ChoiceAfterRun(ctx context.Context, db Querier, profileID, runID string) (MadeChoice, bool, error)

ChoiceAfterRun is the choice the end of the profile's lesson run gave, and whether it gave one.

type Mark added in v0.1.18

type Mark struct {
	LearnerModel string
	Release      string
	Window       string
}

Mark is what the cache of a profile's skill state was computed on: the version of learner-model, the release of modules and the window of the format's versions. An empty field is a cache never written.

type ModuleChoices added in v0.1.19

type ModuleChoices struct {
	ModuleID string
	Choices  int64
}

ModuleChoices is how many choices of a module the profile had, a lesson's counted once.

func ChoicesByModule added in v0.1.19

func ChoicesByModule(ctx context.Context, db Lister, profileID string) ([]ModuleChoices, error)

ChoicesByModule is how many choices the profile had of each module.

type NewAttempt added in v0.1.15

type NewAttempt struct {
	PackageDigest string
	ModuleID      string
	ModuleVersion string
	FormatVersion string
	ModuleKit     string
	TaskID        string
	Seed          uint64
	Instance      *int
	ChoiceID      *string
	PreviousID    *string
	// LessonRunID and Segment are the run and the place of the segment of an
	// attempt of a lesson's task.
	LessonRunID *string
	Segment     *int
}

NewAttempt is what an attempt begins with: its package, the versions its verdict repeats by, its task, seed and instance, and one of the three ways it begins.

type NewChoice added in v0.1.19

type NewChoice struct {
	Kind        string
	ModuleID    string
	TaskID      string
	LessonID    string
	NotAdmitted bool
	// Closed is why the AI that checks the tasks was closed, beside nothing to
	// give when it left a task out: a word of NothingCauses, with NextDay beside
	// the quota.
	Closed        string
	NextDay       *time.Time
	ReasonCode    int
	IssuedSkills  []string
	PackageDigest string
	MapSkill      string
	AgeCategory   string
	Grade         *int
	PoolLimited   bool
	Mark          Mark
	EngineVersion string
	LastSeq       int64
	Digests       []string
	EngineDigests []string
	// AfterAttemptID and AfterLessonRunID name the close of an attempt or the end
	// of a run that gave the choice as what comes next.
	AfterAttemptID   *string
	AfterLessonRunID *string
}

NewChoice is an engine's choice as it is written: what it gives — a task, a lesson or nothing, with the outcome "not admitted" or none —, its reason code, the skills it handed out and the package it was made on, and the input a replay needs — the skill chosen on the skill map, the age category and the grade of the profile, whether the pool was limited to the tasks a tap checks, the versions, the release and the window, the number of the last evidence read, and the digests of the graphs —, with the close or the end of a run whose next it is, when it is one.

type NewConsent added in v0.1.21

type NewConsent struct {
	AgeCategory string
	Country     string
	Applied     int
	Giver       string
	RequestCode string
	TextVersion *int32
}

NewConsent is a consent for a child as it is asked for: the category of the learner, the country, the age of the country it was given by, who gives it, and, for a parent's, the code of its request and the version of parent-consent.

type NewRun added in v0.1.17

type NewRun struct {
	LessonID      string
	ModuleID      string
	ModuleVersion string
	PackageDigest string
	ChoiceID      string
}

NewRun is what a lesson run begins with: the lesson, its module and version, the package, and the engine's choice that opens it.

type OpenAttempt added in v0.1.15

type OpenAttempt struct {
	ID          string
	LessonRunID *string
	Segment     *int
}

OpenAttempt is a profile's open attempt, as the list of profiles names it: its ID, and its lesson run and segment when it is one of a run.

func RunAttempt added in v0.1.17

func RunAttempt(ctx context.Context, tx pgx.Tx, profileID, runID string) (OpenAttempt, bool, error)

RunAttempt is the run's open attempt and the place of its segment, and whether it has one.

type OpenLessonRun added in v0.1.17

type OpenLessonRun struct {
	ID            string
	LessonID      string
	PackageDigest string
}

OpenLessonRun is a profile's open lesson run, as the list of profiles names it: its ID, the lesson's full ID and its package.

type OpenOn added in v0.1.20

type OpenOn struct {
	ID        string
	ProfileID string
	AccountID string
}

OpenOn is an open attempt or lesson run the job after a rollout closes: its ID, with its profile and account.

func OpenAttemptsOn added in v0.1.20

func OpenAttemptsOn(ctx context.Context, db Lister, digests []string, after string, limit int) ([]OpenOn, error)

OpenAttemptsOn is up to limit open attempts on the packages of digests, whose ID comes after after, by ID, of accounts no deletion marked: those whose package the image does not give. An account marked goes with its attempts.

func OpenRunsOn added in v0.1.20

func OpenRunsOn(ctx context.Context, db Lister, digests []string, after string, limit int) ([]OpenOn, error)

OpenRunsOn is OpenAttemptsOn for the open lesson runs.

type Owed added in v0.1.18

type Owed struct {
	ID                  string
	PackageDigest       string
	ModuleID            string
	TaskID              string
	Instance            *int
	CloseReason         string
	WrongAnswers        int
	LastActionAt        time.Time
	StepTechniques      bool
	RequestedTechniques bool
	LeadingQuestion     bool
	ExplainedAgain      int
	SolutionSeenBefore  bool
	Answers             [][]byte
}

Owed is a closed attempt whose evidence is not in the journal yet, with what its evidence is built of: what it was of, how it closed, its last action, the techniques given at a step and on request, whether a hint asked for gave the task's leading question, how many times "explain differently" was asked for, whether the solution of its task reached the device before it began, and the answers of its submissions, in order.

func OwedAttempts added in v0.1.18

func OwedAttempts(ctx context.Context, tx pgx.Tx, profileID string, digests []string) ([]Owed, error)

OwedAttempts is the profile's attempts that owe their evidence, on the packages digests names — those the image holds: one whose package left the image gives none, as its evidence is built from the package —, in the order they closed.

type Profile added in v0.1.5

type Profile struct {
	ID                string
	Owner             bool
	Pseudonym         string
	Avatar            string
	AgeCategory       string
	Country           string
	VoicingEnabled    bool
	VoicingSpeed      string
	DefaultMode       string
	InterfaceLanguage *string
	Grade             *int16
	AskBeforeShowing  bool
	// HintMode is "show_where" or "questions_only".
	HintMode string
	// WorkStorage says the storage of the learner's works on the server is on.
	WorkStorage bool
	// AgeStatedOn is the day the age was last given, by UTC: a year after it, the
	// category is refined.
	AgeStatedOn *time.Time
	// Consent is the profile's consent, which AccountView and ProfileWithConsent
	// read.
	Consent Consent
	// OpenAttempt is the profile's open attempt, which the view of the account
	// alone reads: nil when it has none.
	OpenAttempt *OpenAttempt
	// OpenLessonRuns are the profile's open lesson runs, one at most for each
	// lesson, which the view of the account alone reads.
	OpenLessonRuns []OpenLessonRun
}

Profile is a profile's row, with the contract's codes as the schema keeps them.

func CreateChildProfile added in v0.1.7

func CreateChildProfile(ctx context.Context, tx pgx.Tx, accountID string, c Consent, p Profile) (Profile, error)

CreateChildProfile makes the profile of a confirmed consent, which ConsentFor held, of its category and country, binds the consent to it, and makes the row of its skill state. The date the age was given is the date the consent was asked for, by UTC.

func CreateOwnerProfile added in v0.1.7

func CreateOwnerProfile(ctx context.Context, tx pgx.Tx, accountID string, p Profile) (Profile, error)

CreateOwnerProfile makes the owner's profile in tx, of the category adult by the owner's statement, with its consent: confirmed now, given by that statement, and the row of its skill state. The date the age was given is the date of the statement, and every date is by UTC, as TouchProfile writes it. The account has one owner's profile: a second is ErrProfileExists.

func ProfileFor added in v0.1.7

func ProfileFor(ctx context.Context, tx pgx.Tx, accountID, profileID string) (Profile, error)

ProfileFor is the account's profile, held FOR UPDATE in tx for a change, or ErrNoProfile.

func ProfileWithConsent added in v0.1.21

func ProfileWithConsent(ctx context.Context, db Querier, accountID, profileID string) (Profile, error)

ProfileWithConsent is the account's profile with its consent, as an answer gives it, or ErrNoProfile.

type ProfileRef added in v0.1.9

type ProfileRef struct {
	AccountID string
	ID        string
}

ProfileRef is a profile the daily job works on, with its account.

func IdleProfiles added in v0.1.9

func IdleProfiles(ctx context.Context, db Lister, before time.Time, after string, limit int) ([]ProfileRef, error)

IdleProfiles is up to limit profiles of accounts not marked, active last before before, whose ID comes after after, by ID: those the daily job deletes after 12 months without activity (П-9).

type Progress added in v0.1.83

type Progress struct {
	Going         bool
	Model, Models int
}

Progress is how far a request going has got: whether one is going, and the place of the model that reads its work, from 0, of a list of models; both 0 while it has noted none.

func CheckProgress added in v0.1.83

func CheckProgress(ctx context.Context, db Querier, accountID, profileID, attemptID, method string, goingFor time.Duration) (Progress, error)

CheckProgress is the progress of the request of method going on the profile's attempt under the account, the latest of them, made less than goingFor ago: an older one is of a request that fell. None is going false.

type Querier added in v0.1.4

type Querier interface {
	QueryRow(ctx context.Context, sql string, args ...any) pgx.Row
	Exec(ctx context.Context, sql string, args ...any) (pgconn.CommandTag, error)
}

Querier is what a read runs on: a pool, a connection or a transaction.

type Record added in v0.1.18

type Record struct {
	ID            string
	PackageDigest string
	TaskID        string
	ModuleID      string
	ModuleVersion string
	LessonID      *string
	CloseReason   *string
	WrongAnswers  int
	StartedAt     time.Time
	ClosedAt      *time.Time
	ChosenAt      *time.Time
	ReasonCode    *int
}

Record is an attempt in the progress of a profile: what it was of, on which package, the lesson of its run, how it closed, when it began and closed, and when the engine chose its task — or its run's lesson — and why: none for an attempt begun again, or by a choice with no reason code.

func ProgressPage added in v0.1.18

func ProgressPage(ctx context.Context, db Lister, profileID string, after *Cursor, n int) ([]Record, error)

ProgressPage is up to n of the profile's attempts of modules, newest first, after the cursor when it is given.

type Report added in v0.1.21

type Report struct {
	ID        string
	AttemptID string
	Reply     string
	Rung      *int16
	Words     string
	Kind      string
	Text      string
	CreatedAt time.Time
}

Report is a problem report of an adult on a reply of the tutor.

type ReportToReview added in v0.1.21

type ReportToReview struct {
	Report
	ReviewBy time.Time
}

ReportToReview is a problem report the operator reads, with the day it is to be reviewed by.

func ReportsToReview added in v0.1.21

func ReportsToReview(ctx context.Context, db Lister, within time.Duration) ([]ReportToReview, error)

ReportsToReview is every report not reviewed yet, by when it came.

type Restated added in v0.1.21

type Restated struct {
	AgeCategory string
	Country     string
	Applied     int
	// Giver is who gives the consent the profile needs after; empty keeps the
	// one it has.
	Giver       string
	RequestCode string
	TextVersion *int32
}

Restated is what a profile's age given again sets: the category and the country, the age of the country it was given by, and the consent it needs after — the one it has, kept, or a new one, which waits: the learner's, or a parent's by a new code.

type Run added in v0.1.19

type Run struct {
	ID            string
	LessonID      string
	ModuleID      string
	PackageDigest string
	EndReason     *string
	EndedAt       *time.Time
}

Run is a lesson run of the profile as the engine's input reads it: its ID, its lesson, its package, and how and when it ended, while it has.

func ProfileRuns added in v0.1.19

func ProfileRuns(ctx context.Context, db Lister, profileID string) ([]Run, error)

ProfileRuns is the profile's lesson runs, in the order they began.

type Rung added in v0.1.17

type Rung struct {
	Rung      int
	Words     Words
	Explained bool
	Other     Words
}

Rung is what an attempt keeps of one of its rungs: its words, and, once "explain differently" was asked for on it, the words that came of it, which the learner reads from then on. The words are empty once the attempt has closed.

func RungOf added in v0.1.17

func RungOf(ctx context.Context, db Querier, profileID, attemptID string, rung int) (Rung, bool, error)

RungOf is the attempt's rung, and whether it has its words.

func (Rung) Current added in v0.1.17

func (r Rung) Current() Words

Current is the words the learner reads on the rung.

type SentForm added in v0.1.21

type SentForm struct {
	RequestCode string
	Object      string
	MediaType   string
	SentAt      time.Time
}

SentForm is a parent's consent whose form the operator checks: its code and where its scan lies.

func SentForms added in v0.1.21

func SentForms(ctx context.Context, db Lister) ([]SentForm, error)

SentForms is every parent's consent that waits with its form sent, by when it was sent.

type Settled added in v0.1.34

type Settled struct {
	Day quota.Day
	// Caps are the caps of the account's tariff, and Capped is false when it has
	// none: platform AI is closed to it, and there is no share.
	Caps             quota.Caps
	Capped           bool
	Profile, Account quota.Micro
}

Settled is what a profile and its account have spent of the quota of a family day, as their calls were settled, without the reserves of calls still going, beside the caps of the account's tariff: what the share of the quota counts by.

func QuotaSettled added in v0.1.34

func QuotaSettled(ctx context.Context, q Querier, accountID, profileID string, now time.Time, offDeployment bool) (Settled, error)

QuotaSettled is what the account's profile and the account have spent of the quota on the family day the account keeps at now, read in q and writing nothing, as Today: the request carries no offset. A profile the account does not have is ErrNoProfile. q is best a snapshot, so that the day, the tariff and the counters are of one moment. A tariff of the dev projects alone has caps only offDeployment, as for a reserve.

type SkillState added in v0.1.18

type SkillState struct {
	State   []byte
	Mark    Mark
	LastSeq int64
}

SkillState is a profile's row of the cache of the skill state: the state as learner-model's codec gives it, empty while it was never written, its mark, and the number of the last evidence it holds.

func HoldSkillState added in v0.1.18

func HoldSkillState(ctx context.Context, tx pgx.Tx, profileID string) (SkillState, error)

HoldSkillState holds the profile's row of the cache FOR UPDATE in tx, so that the evidence of one profile is numbered and folded one piece after another. The profile's own row is held FOR KEY SHARE first, as the rows of the journal that the caller then adds refer to it: a deletion of the profile, which takes it FOR UPDATE before its cascade reaches the cache, waits, rather than locking the two rows in the other order. A profile may have no row of the cache, so the row is made first, empty, when it is not there; a profile gone is ErrNoProfile.

type Solution added in v0.1.19

type Solution struct {
	ModuleID string
	TaskID   string
	At       time.Time
}

Solution is when the solution of a task of a module last went to the profile's device: an attempt of it closed correct or with the solution shown.

func SolutionsSent added in v0.1.19

func SolutionsSent(ctx context.Context, db Lister, profileID string) ([]Solution, error)

SolutionsSent is when the solution of each of the profile's tasks last went to its device.

type TextRef added in v0.1.21

type TextRef struct {
	ID      string
	Version int32
}

TextRef is a version of a legal text.

type TxBeginner added in v0.1.5

type TxBeginner interface {
	BeginTx(ctx context.Context, options pgx.TxOptions) (pgx.Tx, error)
}

TxBeginner is what a transaction with its options starts from: a pool, or a connection.

type View added in v0.1.5

type View struct {
	// ID is the account's ID.
	ID string
	// PinSet says the PIN of the section for adults is set.
	PinSet bool
	// Profiles are the account's profiles: the owner's first, then by when they
	// were created.
	Profiles []Profile
	// ChildConsents are the consents for a child that have no profile, by when
	// they were asked for.
	ChildConsents []ChildConsent
}

View is the account as GetAccount gives it: whether its PIN is set, its profiles with their open attempts and lesson runs, and its consents for a child with no profile yet.

func AccountView added in v0.1.5

func AccountView(ctx context.Context, db TxBeginner, accountID string) (View, error)

AccountView reads the account in one snapshot, so that its profiles and its consents are of one moment: a device erases the profiles the list does not hold. An account that is not there is ErrNoAccount, and one marked "deleting" ErrAccountDeleting.

type Words added in v0.1.17

type Words struct {
	Source string
	Text   string
}

Words are the words of a rung and where they came from.

type Work added in v0.1.39

type Work struct {
	AttemptID string
	Kind      string
	SizeBytes int64
	StoredAt  time.Time
	Bytes     []byte
}

Work is a stored work of a profile: the attempt whose work it is, what it is, its size as the contract counts it, when api kept it, and, where it is read whole, its bytes — the contract's StoredWork in binary protobuf, which the store does not read.

func GetWork added in v0.1.39

func GetWork(ctx context.Context, db Querier, profileID, attemptID string) (Work, error)

GetWork is the profile's stored work of the attempt, with its bytes, or ErrNotFound.

func ListWorks added in v0.1.39

func ListWorks(ctx context.Context, db Lister, profileID string) ([]Work, error)

ListWorks is the profile's stored works, newest first, without their bytes.

Directories

Path Synopsis
Package storetest runs the tests of api's database on a real PostgreSQL with no Docker, as the devcontainer and CI have none: embedded-postgres starts one server for a test binary, when its first test asks for a database, migrates a template database once, and gives each test a database of its own made from it, which is a copy and takes milliseconds.
Package storetest runs the tests of api's database on a real PostgreSQL with no Docker, as the devcontainer and CI have none: embedded-postgres starts one server for a test binary, when its first test asks for a database, migrates a template database once, and gives each test a database of its own made from it, which is a copy and takes milliseconds.

Jump to

Keyboard shortcuts

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