Help us shape the future of Go! Take the 2026 Go Developer Survey

popularity

package
v0.131.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package popularity prepares reusable UTC-day participation counts and ranks available works by their mean daily readers/(eligible population+20). See docs/popularity-policy.md for qualification and whole-day eligibility.

Index

Constants

View Source
const DefaultPeriod = "30d"

DefaultPeriod is the window a listing gets when it names none.

Variables

View Source
var Periods = []string{"7d", "30d", "90d", "365d", "all"}

Periods are the only public popularity windows: literal whole-UTC-day windows with equal weight inside, "all" unbounded.

Functions

func Prepare added in v0.131.0

func Prepare(ctx context.Context, source Source, availability AvailabilityProvider, kind string, until time.Time, scope signal.ActivityScope) (signal.Window, error)

Prepare prepares every known day once per kind/scope in the existing worker. It retains closed days independently of configured preset windows. Until is the worker's single refresh-cycle time, not a reader-supplied query boundary. Returned coverage contains only successfully prepared UTC days.

func Rank added in v0.128.6

func Rank(ctx context.Context, source Source, _ AvailabilityProvider, kind string, window signal.Window, scope signal.ActivityScope, limit int) ([]string, error)

Rank reads only the prepared daily scalars. Public requests may read an arbitrary whole-day range after checking DailyPopularityCoverage; they never invoke preparation or scan raw receipts.

func Rebuild added in v0.131.0

func Rebuild(ctx context.Context, source Source, availability AvailabilityProvider, kind string, until time.Time, scope signal.ActivityScope) (signal.Window, error)

Rebuild explicitly recalculates historical corrections/imports. It reports errors and creates no scheduled repair work.

func WindowForPeriod

func WindowForPeriod(period string, now time.Time) (signal.Window, error)

WindowForPeriod maps a public period onto the window ending on now's UTC day. Anything else is an error, never a silent default.

Types

type AvailabilityProvider added in v0.98.0

type AvailabilityProvider interface {
	Availability(ctx context.Context, kind string, window signal.Window, scope signal.ActivityScope, contents []string) (signal.Availability, error)
}

AvailabilityProvider supplies immutable publication and access history.

type Source

type Source interface {
	PrepareDailyPopularity(ctx context.Context, kind string, availability signal.Availability, scope signal.ActivityScope, rebuild bool) (signal.DailyPopularityPreparation, error)
	DailyPopular(ctx context.Context, kind string, window signal.Window, scope signal.ActivityScope, limit int) ([]signal.PopularHit, error)
	DailyPopularityCoverage(ctx context.Context, kind string, scope signal.ActivityScope) (signal.Window, bool, error)
	PopulationCoverage(ctx context.Context, kind string, scope signal.ActivityScope, window signal.Window) (time.Time, bool, error)
}

Source is one tenant's signal plane; the engine's hub satisfies it.

Jump to

Keyboard shortcuts

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