visitor

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CollectStats

type CollectStats struct {
	// /stats?album=featured&img=3d3kr8ydrb8l4&time=4169&w=1475&h=983&mw=1620&mh=1080&sw=1920&sh=1080&px=2&v=k...g
	// /stats?album=featured&img=1om86jo4rku2r&time=391&w=1620&h=1080&mw=1621&mh=1080&sw=1920&sh=1080&px=2&v=k...g
	// /stats?main=1&sw=1920&sh=1080&px=2&v=k...g
	// /stats?thumb=%7B%2234suxvlfx0lz8%22%3A36704%2C%221z4zoegvmke8n%22%3A36704%2C%223b45tgt52cnms%22%3A36704%2C%221d2ujpqi6nbb4%22%3A36704%2C%221shlwpftv8av4%22%3A36704%7D&sw=1792&sh=1120&px=2&v=1...w
	request.EmbeddedSetter

	Visitor uniq.Hash `query:"v" description:"Visitor."`
	Referer string    `query:"ref" description:"Referer."`

	ScreenWidth  int     `query:"sw" description:"Screen width."`
	ScreenHeight int     `query:"sh" description:"Screen height."`
	PixelRatio   float64 `query:"px" description:"Device pixel ratio (retina factor)."`

	Main               bool              `query:"main" description:"Main page shown."`
	Album              string            `query:"album" description:"Album with a name shown."`
	Thumb              map[uniq.Hash]int `query:"thumb" collectionFormat:"json" description:"Thumb on-screen times, ms."`
	MobilePortraitMode bool              `query:"prt" description:"Mobile portrait mode."`

	Image     uniq.Hash `query:"img" description:"Image with a hash is shown individually."`
	Width     int       `query:"w" description:"Shown width of the image."`
	Height    int       `query:"h" description:"Shown height of the image."`
	MaxWidth  int       `query:"mw" description:"Max shown width of the image (zoom)."`
	MaxHeight int       `query:"mh" description:"Max shown height of the image (zoom)."`
	Time      int       `query:"time" description:"Image view time, ms."`
}

type DailyPageStats

type DailyPageStats struct {
	PageStats
	Date int64 `db:"date" description:"Date as truncated unix timestamp"`
}

type PageStats

type PageStats struct {
	Hash   uniq.Hash `db:"hash" description:"Album hash or 0 for main page"`
	Views  int       `db:"views" description:"Total views count."`
	Uniq   int       `db:"uniq" description:"Total unique viewers count."`
	Refers int       `db:"refers" description:"Total referer views count."`
}

type StatsRepository

type StatsRepository struct {
	// contains filtered or unexported fields
}

func NewStats

func NewStats(st *sqluct.Storage, l ctxd.Logger) (*StatsRepository, error)

func (*StatsRepository) CollectAlbum

func (s *StatsRepository) CollectAlbum(ctx context.Context, visitor, album uniq.Hash, referer string, date time.Time)

func (*StatsRepository) CollectImage

func (s *StatsRepository) CollectImage(ctx context.Context, visitor, image uniq.Hash, viewTimeMs int, zoomedIn bool)

func (*StatsRepository) CollectMain

func (s *StatsRepository) CollectMain(ctx context.Context, visitor uniq.Hash, referer string, date time.Time)

func (*StatsRepository) CollectRefer

func (s *StatsRepository) CollectRefer(ctx context.Context, visitor uniq.Hash, ts time.Time, referer, url string)

func (*StatsRepository) CollectRequest

func (s *StatsRepository) CollectRequest(ctx context.Context, input CollectStats, ts time.Time)

func (*StatsRepository) CollectThumbs

func (s *StatsRepository) CollectThumbs(ctx context.Context, visitor uniq.Hash, mobilePortraitMode bool, thumbs map[uniq.Hash]int)

func (*StatsRepository) CollectVisitor

func (s *StatsRepository) CollectVisitor(h uniq.Hash, isBot, isAdmin bool, ts time.Time, r *http.Request)

func (*StatsRepository) DB

func (s *StatsRepository) DB() *sql.DB

func (*StatsRepository) DailyTotal

func (s *StatsRepository) DailyTotal(ctx context.Context, minDate, maxDate time.Time) ([]DailyPageStats, error)

func (*StatsRepository) IsAdmin

func (s *StatsRepository) IsAdmin(v uniq.Hash) bool

Jump to

Keyboard shortcuts

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