api

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: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnimeRanking

type AnimeRanking struct {
	Completed int     `json:"completed"`
	Dropped   int     `json:"dropped"`
	TotalDays float64 `json:"totalDays"`
	Episodes  int     `json:"episodes"`
}

AnimeRanking contains anime ranking information for single user. To be used in API response.

type Cache

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

Cache is a main cache container

func GetCache

func GetCache(db *gorm.DB) *Cache

GetCache creates new Cache instance with initial values

func (*Cache) GetCount

func (c *Cache) GetCount() int

GetCount returns number of all users in the database

func (*Cache) GetStats

func (c *Cache) GetStats(kind string, filter string) data.Stats

GetStats returns data about global statustics. It will reuse cached data if possible.

func (*Cache) GetUser

func (c *Cache) GetUser(username string) (*UserStats, error)

GetUser returns data about single user. It will reuse cached data if possible.

type Handlers

type Handlers struct {
	DB    *gorm.DB
	Cache *Cache
}

Handlers contains reference to the database and all handlers

func (*Handlers) GetGlobalStats

func (h *Handlers) GetGlobalStats(w http.ResponseWriter, r *http.Request)

GetGlobalStats returns JSON info about global stats

func (*Handlers) GetUserStats

func (h *Handlers) GetUserStats(w http.ResponseWriter, r *http.Request)

GetUserStats returns JSON info about single user

type MangaRanking

type MangaRanking struct {
	Completed int     `json:"completed"`
	Dropped   int     `json:"dropped"`
	TotalDays float64 `json:"totalDays"`
	Chapters  int     `json:"chapters"`
	Volumes   int     `json:"volumes"`
}

MangaRanking contains manga ranking information for single user. To be used in API response.

type Ranking

type Ranking struct {
	Anime AnimeRanking `json:"anime"`
	Manga MangaRanking `json:"manga"`
}

Ranking contains ranking information for single user. To be used in API response.

func DBRankingToSchema

func DBRankingToSchema(fromDb core.Ranking) Ranking

DBRankingToSchema maps DB structure into API, JSONable structure

type UserStats

type UserStats struct {
	Username        string          `json:"username"`
	Age             int             `json:"age"`
	LastUpdate      time.Time       `json:"lastUpdate"`
	AnimeStats      core.AnimeStats `json:"animeStats"`
	MangaStats      core.MangaStats `json:"mangaStats"`
	Ranking         Ranking         `json:"ranking"`
	TotalUsersCount int             `json:"totalUsers"`
}

UserStats contains response structure for single user

Jump to

Keyboard shortcuts

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