core

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OpenDb

func OpenDb() *gorm.DB

OpenDb opens connection to database based on config

func SaveRelations

func SaveRelations(db *gorm.DB, relations []Relation)

SaveRelations stores multiple relation in the database

Types

type AnimeStats

type AnimeStats struct {
	UserID     uint      `gorm:"primary_key"`
	UpdatedAt  time.Time `json:"-"`
	InProgress int       `json:"inProgress"`
	Completed  int       `json:"completed"`
	OnHold     int       `json:"onHold"`
	Dropped    int       `json:"dropped"`
	Planned    int       `json:"planned"`
	Rewatched  int       `json:"rewatched"`
	Days       float64   `json:"totalDays"`
	MeanScore  float64   `json:"meanScore"`
	Episodes   int       `json:"totalEpisodes"`
}

AnimeStats is structure for holding anime statistics

type BasicInfo

type BasicInfo struct {
	Birthday pq.NullTime
	Gender   string
	Location string
}

BasicInfo holds info about user without any database info

type Configuration

type Configuration struct {
	Database dbConfig
	Scraper  scraperConfig
	API      apiConfig
}

Configuration holds database settings

func ReadConfig

func ReadConfig() *Configuration

ReadConfig returns config from JSON file

type GlobalStats

type GlobalStats struct {
	ID                uint      `gorm:"primary_key"`
	UpdatedAt         time.Time `json:"-"`
	Users             int
	BirthYear         int
	Gender            string
	AnimeCompletedSum int
	AnimeCompletedAvg int
	AnimeDroppedSum   int
	AnimeDroppedAvg   int
	AnimeDaysSum      int
	AnimeDaysAvg      int
	MangaCompletedSum int
	MangaCompletedAvg int
	MangaDroppedSum   int
	MangaDroppedAvg   int
	MangaDaysSum      int
	MangaDaysAvg      int
}

GlobalStats holds info about ranking for all users grouped by birth year and gender

type MangaStats

type MangaStats struct {
	UserID     uint      `gorm:"primary_key"`
	UpdatedAt  time.Time `json:"-"`
	InProgress int       `json:"inProgress"`
	Completed  int       `json:"completed"`
	OnHold     int       `json:"onHold"`
	Dropped    int       `json:"dropped"`
	Planned    int       `json:"planned"`
	Rewatched  int       `json:"rewatched"`
	Days       float64   `json:"totalDays"`
	MeanScore  float64   `json:"meanScore"`
	Chapters   int       `json:"totalChapters"`
	Volumes    int       `json:"totalVolumes"`
}

MangaStats is structure for holding manga statistics

type Ranking

type Ranking struct {
	TemporaryRanking
}

Ranking holds info about user's ranking

type Relation

type Relation struct {
	User1ID uint
	User2ID uint
}

Relation - `from` user having `to` as friend

func NewRelation

func NewRelation(user1 *User, user2 *User) Relation

NewRelation returns Relation where users are alphabetized

type TemporaryRanking

type TemporaryRanking struct {
	UserID         uint      `gorm:"primary_key"`
	UpdatedAt      time.Time `json:"-"`
	CompletedAnime int
	CompletedManga int
	DroppedAnime   int
	DroppedManga   int
	TotalDaysAnime float64
	TotalDaysManga float64
	EpisodesAnime  int
	ChaptersManga  int
	VolumesManga   int
}

TemporaryRanking holds info about user's ranking temporarily when table is recreated

type User

type User struct {
	ID          uint      `gorm:"primary_key"`
	CreatedAt   time.Time `json:"-"`
	UpdatedAt   time.Time `json:"-"`
	Username    string
	DisplayName string
	Birthday    pq.NullTime `gorm:"type:date"`
	Gender      string
	Location    string
	Fetched     bool `gorm:"index"`
	Fetching    bool `gorm:"index"`
	AnimeStats  AnimeStats
	MangaStats  MangaStats
	Ranking     Ranking
}

User holds info about user and whether they were fetched

Jump to

Keyboard shortcuts

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