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
- Variables
- func Prepare(ctx context.Context, source Source, availability AvailabilityProvider, ...) (signal.Window, error)
- func Rank(ctx context.Context, source Source, _ AvailabilityProvider, kind string, ...) ([]string, error)
- func Rebuild(ctx context.Context, source Source, availability AvailabilityProvider, ...) (signal.Window, error)
- func WindowForPeriod(period string, now time.Time) (signal.Window, error)
- type AvailabilityProvider
- type Source
Constants ¶
const DefaultPeriod = "30d"
DefaultPeriod is the window a listing gets when it names none.
Variables ¶
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.
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.