data

package
v0.0.0-...-81a70f6 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2018 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateStatsTable

func GenerateStatsTable(db *gorm.DB)

GenerateStatsTable recreates stats table in database

func MarkUsersToFetch

func MarkUsersToFetch(db *gorm.DB)

MarkUsersToFetch marks users with stale data to refresh

Types

type RankingManager

type RankingManager struct {
	DB *gorm.DB
}

RankingManager is able to recreate ranking tables

func (*RankingManager) MigrateRankingResults

func (m *RankingManager) MigrateRankingResults()

MigrateRankingResults moves data from temporary to target table. Target table will be dropped.

func (*RankingManager) PopulateTemporaryRankingTable

func (m *RankingManager) PopulateTemporaryRankingTable()

PopulateTemporaryRankingTable fills temporary ranking table based on raw anime/manga data

func (*RankingManager) RecreateTemporaryRankingTable

func (m *RankingManager) RecreateTemporaryRankingTable()

RecreateTemporaryRankingTable recreates temporary ranking table

type Stats

type Stats map[string]StatsKind

Stats holds data for whole response

func GetGlobalStats

func GetGlobalStats(db *gorm.DB, kind string, filter string) Stats

GetGlobalStats extracts appropriate stats from database

type StatsEntry

type StatsEntry struct {
	Count  int `json:"count"`
	Mean   int `json:"mean"`
	Median int `json:"median"`
}

StatsEntry holds data for single "cell" in stats response

type StatsKind

type StatsKind struct {
	Completed StatsEntry `json:"completed"`
	Dropped   StatsEntry `json:"dropped"`
	TotalDays StatsEntry `json:"total_days"`
}

StatsKind holds data for single group in stats response

type StatsRow

type StatsRow struct {
	Users        int
	BirthYear    int
	Gender       string
	CompletedSum int
	CompletedAvg int
	DroppedSum   int
	DroppedAvg   int
	DaysSum      int
	DaysAvg      int
}

StatsRow is used to map DB results to response

Jump to

Keyboard shortcuts

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