models

package
v2.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2018 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package models contains everything that is needed to interface to the database CheeseGull is using.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BiggestSetID

func BiggestSetID(db *sql.DB) (int, error)

BiggestSetID retrieves the biggest set ID in the sets database. This is used by discovery to have a starting point from which to discover new beatmaps.

func CreateBeatmaps

func CreateBeatmaps(db *sql.DB, bms ...Beatmap) error

CreateBeatmaps adds beatmaps in the database.

func CreateSet

func CreateSet(db *sql.DB, s Set) error

CreateSet creates (and updates) a beatmap set in the database.

func DeleteSet

func DeleteSet(db *sql.DB, set int) error

DeleteSet deletes a set from the database, removing also its children beatmaps.

func RunMigrations

func RunMigrations(db *sql.DB) error

RunMigrations brings the database up to date following the migrations.

Types

type Beatmap

type Beatmap struct {
	ID               int `json:"BeatmapID"`
	ParentSetID      int
	DiffName         string
	FileMD5          string
	Mode             int
	BPM              float64
	AR               float32
	OD               float32
	CS               float32
	HP               float32
	TotalLength      int
	HitLength        int
	Playcount        int
	Passcount        int
	MaxCombo         int
	DifficultyRating float64
}

Beatmap represents a single beatmap (difficulty) on osu!.

func FetchBeatmaps

func FetchBeatmaps(db *sql.DB, ids ...int) ([]Beatmap, error)

FetchBeatmaps retrieves a list of beatmap knowing their IDs.

type SearchOptions

type SearchOptions struct {
	// If len is 0, then it should be treated as if all statuses are good.
	Status []int
	Query  string
	// Gamemodes to which limit the results. If len is 0, it means all modes
	// are ok.
	Mode []int

	// Pagination options.
	Offset int
	Amount int
}

SearchOptions are options that can be passed to SearchSets for filtering sets.

type Set

type Set struct {
	ID               int `json:"SetID"`
	ChildrenBeatmaps []Beatmap
	RankedStatus     int
	ApprovedDate     time.Time
	LastUpdate       time.Time
	LastChecked      time.Time
	Artist           string
	Title            string
	Creator          string
	Source           string
	Tags             string
	HasVideo         bool
	Genre            int
	Language         int
	Favourites       int
}

Set represents a set of beatmaps usually sharing the same song.

func FetchSet

func FetchSet(db *sql.DB, id int, withChildren bool) (*Set, error)

FetchSet retrieves a single set to show, alongside its children beatmaps.

func FetchSetsForBatchUpdate

func FetchSetsForBatchUpdate(db *sql.DB, limit int) ([]Set, error)

FetchSetsForBatchUpdate fetches limit sets from the database, sorted by LastChecked (asc, older first). Results are further filtered: if the set's RankedStatus is 3, 0 or -1 (qualified, pending or WIP), at least 30 minutes must have passed from LastChecked. For all other statuses, at least 4 days must have passed from LastChecked.

func SearchSets

func SearchSets(db, searchDB *sql.DB, opts SearchOptions) ([]Set, error)

SearchSets retrieves sets, filtering them using SearchOptions.

Jump to

Keyboard shortcuts

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