Documentation
¶
Overview ¶
MIT License: https://github.com/prplecake/go-thumbnail Package thumbnail provides a method to create thumbnails from images.
Index ¶
- Constants
- Variables
- func AESDecrypt(key string, iv []byte, encryptedData []byte) (decrypted []byte, err error)
- func CheckPassword(input string, bcryptString string) bool
- func CheckPasswordHashed(inputHashed []byte, bcryptString string) bool
- func CheckPasswordHashedHex(inputHex string, bcryptString string) bool
- func ClearPasswordCache()
- func CreateBeatmap(beatmap *Beatmap, state *State) error
- func CreateBeatmaps(beatmaps []Beatmap, state *State) error
- func CreateBeatmapset(beatmapset *Beatmapset, state *State) error
- func CreateDatabaseSession(config *DatabaseConfiguration) (*gorm.DB, error)
- func CreateForum(forum *Forum, state *State) error
- func CreatePasswordHash(password string) (string, error)
- func CreatePost(post *ForumPost, state *State) error
- func CreateRedisSession(ctx context.Context, config *RedisConfiguration) (*redis.Client, error)
- func CreateScore(score *Score, state *State) error
- func CreateStats(stats *Stats, state *State) error
- func CreateTopic(topic *ForumTopic, state *State) error
- func CreateUser(user *User, state *State) error
- func CreateUserRelationship(relationship *Relationship, state *State) error
- func DecryptScoreData(iv []byte, encryptedData []byte) ([]byte, error)
- func DeleteForum(forum *Forum, state *State) error
- func DeletePost(post *ForumPost, state *State) error
- func DeleteScore(score *Score, state *State) error
- func DeleteTopic(topic *ForumTopic, state *State) error
- func ExtractAudioSnippet(audioData []byte, offset int, duration int, bitrate int, storage Storage) ([]byte, error)
- func FetchBeatmapsetCountByCreatorId(userId int, state *State) (int, error)
- func FetchBeatmapsetRankedCountByCreatorId(userId int, state *State) (int, error)
- func FetchBeatmapsetUnrankedCountByCreatorId(userId int, state *State) (int, error)
- func FormatBytes(data []byte) string
- func FormatStruct(s interface{}) string
- func FormatValue(v reflect.Value) string
- func GetClearsRank(userId int, state *State) (int, error)
- func GetCountryClearsRank(userId int, countryCode string, state *State) (int, error)
- func GetCountryScoreRank(userId int, country string, state *State) (int, error)
- func GetCountryTotalScoreRank(userId int, country string, state *State) (int, error)
- func GetPasswordCache() map[string]bool
- func GetSHA512Hash(input string) []byte
- func GetScoreRank(userId int, state *State) (int, error)
- func GetTotalScoreRank(userId int, state *State) (int, error)
- func HandlePanic(err *error)
- func JulianToTime(julianDate float64) time.Time
- func ReadBigIntBE(data []byte) *big.Int
- func ReadU16(data []byte) uint16
- func ReadU16BE(data []byte) uint16
- func ReadU32(data []byte) uint32
- func ReadU32BE(data []byte) uint32
- func ReadU64(data []byte) uint64
- func ReadU64BE(data []byte) uint64
- func ReadU8(data []byte) uint8
- func RemoveBeatmap(beatmap *Beatmap, state *State) error
- func RemoveBeatmapsBySetId(setId int, state *State) error
- func RemoveBeatmapset(beatmapset *Beatmapset, state *State) error
- func RemoveRankingsEntry(stats *Stats, country string, state *State) error
- func RemoveUserRelationship(relationship *Relationship, state *State) error
- func TimeToJulian(t time.Time) float64
- func UnpadPKCS7(data []byte) ([]byte, error)
- func UpdateBeatmap(beatmap *Beatmap, state *State) error
- func UpdateBeatmapset(beatmapset *Beatmapset, state *State) error
- func UpdateForum(forum *Forum, state *State) error
- func UpdatePlaytime(userId int, secondsToAdd int, state *State) error
- func UpdatePost(post *ForumPost, state *State) error
- func UpdateRankingsEntry(stats *Stats, country string, state *State) error
- func UpdateScore(score *Score, state *State) error
- func UpdateStats(stats *Stats, state *State) error
- func UpdateTopic(topic *ForumTopic, state *State) error
- func WriteBigIntBE(value *big.Int, length int) []byte
- func WriteU16[T constraints.Integer](value T) []byte
- func WriteU16BE[T constraints.Integer](value T) []byte
- func WriteU32[T constraints.Integer](value T) []byte
- func WriteU32BE[T constraints.Integer](value T) []byte
- func WriteU64[T constraints.Integer](value T) []byte
- func WriteU64BE[T constraints.Integer](value T) []byte
- func WriteU8[T constraints.Integer](value T) []byte
- type Beatmap
- type BeatmapAvailability
- type BeatmapStatus
- type Beatmapset
- func FetchBeatmapsetById(id int, state *State, preload ...string) (*Beatmapset, error)
- func FetchBeatmapsetsByCreatorId(userId int, state *State, preload ...string) ([]Beatmapset, error)
- func FetchBeatmapsetsByStatus(userId int, status BeatmapStatus, state *State, preload ...string) ([]Beatmapset, error)
- type DatabaseConfiguration
- type ErrorCollection
- func (ec *ErrorCollection) Add(err error)
- func (ec *ErrorCollection) Errors() []error
- func (ec *ErrorCollection) HasErrors() bool
- func (ec *ErrorCollection) Length() int
- func (ec *ErrorCollection) Next() error
- func (ec *ErrorCollection) Pop(index int) error
- func (ec *ErrorCollection) String() string
- type FileStorage
- func (storage *FileStorage) CreateTempFile() (*os.File, error)
- func (storage *FileStorage) DefaultAvatar() ([]byte, error)
- func (storage *FileStorage) Download(url string, key string, folder string) error
- func (storage *FileStorage) EnsureDefaultAvatar() error
- func (storage *FileStorage) GetAvatar(userId int) ([]byte, error)
- func (storage *FileStorage) GetBeatmapFile(beatmapId int) ([]byte, error)
- func (storage *FileStorage) GetBeatmapPackage(beatmapsetId int) ([]byte, error)
- func (storage *FileStorage) GetBeatmapPreview(beatmapId int) ([]byte, error)
- func (storage *FileStorage) GetBeatmapThumbnail(beatmapId int, large bool) ([]byte, error)
- func (storage *FileStorage) GetReplayFile(scoreId int) ([]byte, error)
- func (storage *FileStorage) Read(key string, folder string) ([]byte, error)
- func (storage *FileStorage) Remove(key string, folder string) error
- func (storage *FileStorage) RemoveBeatmapFile(beatmapId int) error
- func (storage *FileStorage) RemoveBeatmapPackage(beatmapsetId int) error
- func (storage *FileStorage) RemoveBeatmapPreview(beatmapId int) error
- func (storage *FileStorage) RemoveBeatmapThumbnail(beatmapId int) error
- func (storage *FileStorage) RemoveReplayFile(scoreId int) error
- func (storage *FileStorage) Save(key string, folder string, data []byte) error
- func (storage *FileStorage) SaveAvatar(userId int, data []byte) error
- func (storage *FileStorage) SaveBeatmapFile(beatmapId int, data []byte) error
- func (storage *FileStorage) SaveBeatmapPackage(beatmapsetId int, data []byte) error
- func (storage *FileStorage) SaveBeatmapPreview(beatmapId int, data []byte) error
- func (storage *FileStorage) SaveBeatmapThumbnail(beatmapId int, data []byte, large bool) error
- func (storage *FileStorage) SaveReplayFile(scoreId int, data []byte) error
- type Forum
- type ForumPost
- type ForumTopic
- type Grade
- type IOStream
- func (stream *IOStream) Available() int
- func (stream *IOStream) Eof() bool
- func (stream *IOStream) Get() []byte
- func (stream *IOStream) Len() int
- func (stream *IOStream) Push(data []byte)
- func (stream *IOStream) Read(size int) []byte
- func (stream *IOStream) ReadAll() []byte
- func (stream *IOStream) ReadBool() bool
- func (stream *IOStream) ReadDateTime() time.Time
- func (stream *IOStream) ReadF32() float32
- func (stream *IOStream) ReadF64() float64
- func (stream *IOStream) ReadI16() int16
- func (stream *IOStream) ReadI32() int32
- func (stream *IOStream) ReadI64() int64
- func (stream *IOStream) ReadI8() int8
- func (stream *IOStream) ReadIntList() []uint32
- func (stream *IOStream) ReadString() string
- func (stream *IOStream) ReadU16() uint16
- func (stream *IOStream) ReadU32() uint32
- func (stream *IOStream) ReadU32Bool() bool
- func (stream *IOStream) ReadU64() uint64
- func (stream *IOStream) ReadU8() uint8
- func (stream *IOStream) Seek(position int)
- func (stream *IOStream) Skip(offset int)
- func (stream *IOStream) Tell() int
- func (stream *IOStream) Write(data []byte)
- func (stream *IOStream) WriteBool(value bool)
- func (stream *IOStream) WriteDateTime(value time.Time)
- func (stream *IOStream) WriteF32(value float32)
- func (stream *IOStream) WriteF64(value float64)
- func (stream *IOStream) WriteI16(value int16)
- func (stream *IOStream) WriteI32(value int32)
- func (stream *IOStream) WriteI64(value int64)
- func (stream *IOStream) WriteI8(value int8)
- func (stream *IOStream) WriteIntList(list []uint32)
- func (stream *IOStream) WriteString(value string)
- func (stream *IOStream) WriteU16(value uint16)
- func (stream *IOStream) WriteU32(value uint32)
- func (stream *IOStream) WriteU32Bool(value bool)
- func (stream *IOStream) WriteU64(value uint64)
- func (stream *IOStream) WriteU8(value uint8)
- type Image
- type ImageDimensions
- type ImageGenerator
- type Logger
- func (c *Logger) Anomaly(msg ...any)
- func (c *Logger) Anomalyf(format string, msg ...any)
- func (c *Logger) Debug(msg ...any)
- func (c *Logger) Debugf(format string, msg ...any)
- func (c *Logger) Error(msg ...any)
- func (c *Logger) Errorf(format string, msg ...any)
- func (c *Logger) GetLevel() int
- func (c *Logger) GetName() string
- func (c *Logger) Info(msg ...any)
- func (c *Logger) Infof(format string, msg ...any)
- func (c *Logger) SetLevel(level int)
- func (c *Logger) SetName(name string)
- func (c *Logger) Verbose(msg ...any)
- func (c *Logger) Verbosef(format string, msg ...any)
- func (c *Logger) Warning(msg ...any)
- func (c *Logger) Warningf(format string, msg ...any)
- type RedisConfiguration
- type Relationship
- type RelationshipStatus
- type ReplayData
- type ReplayFrame
- type ReplayHeader
- type Score
- func FetchBestScores(userId int, beatmapStatus int, state *State) ([]*Score, error)
- func FetchPersonalBest(userId int, beatmapId int, state *State, preload ...string) (*Score, error)
- func FetchRangeScores(beatmapId int, state *State, preload ...string) ([]*Score, error)
- func FetchScoreById(id int, state *State, preload ...string) (*Score, error)
- type ScoreStatus
- type State
- type StateConfiguration
- type Stats
- type Storage
- type User
Constants ¶
const ( QUIET int = 60 ANOMALY int = 50 ERROR int = 40 WARNING int = 30 INFO int = 20 DEBUG int = 10 VERBOSE int = 0 )
const ( ColorReset = "\033[0m" ColorBlack = "\033[30m" ColorRed = "\033[31m" ColorGreen = "\033[32m" ColorYellow = "\033[33m" ColorBlue = "\033[34m" ColorPurple = "\033[35m" ColorCyan = "\033[36m" ColorWhite = "\033[37m" ColorGrey = "\033[0;90m" )
const ( ColorBoldBlack = "\033[1;30m" ColorBoldRed = "\033[1;31m" ColorBoldGreen = "\033[1;32m" ColorBoldYellow = "\033[1;33m" ColorBoldBlue = "\033[1;34m" ColorBoldPurple = "\033[1;35m" ColorBoldCyan = "\033[1;36m" ColorBoldWhite = "\033[1;37m" )
Variables ¶
var ( // ErrInvalidMimeType is returned when a non-image content type is // detected. ErrInvalidMimeType = errors.New("invalid mimetype") // ErrInvalidScaler is returned when an unrecognized scaler is // passed to the Generator. ErrInvalidScaler = errors.New("invalid scaler") )
Functions ¶
func AESDecrypt ¶
func CheckPassword ¶
func CheckPasswordHashed ¶
func CheckPasswordHashedHex ¶
func ClearPasswordCache ¶
func ClearPasswordCache()
func CreateBeatmap ¶
func CreateBeatmaps ¶
func CreateBeatmapset ¶
func CreateBeatmapset(beatmapset *Beatmapset, state *State) error
func CreateDatabaseSession ¶
func CreateDatabaseSession(config *DatabaseConfiguration) (*gorm.DB, error)
func CreateForum ¶
func CreatePasswordHash ¶
func CreatePost ¶
func CreateRedisSession ¶
func CreateScore ¶
func CreateStats ¶
func CreateTopic ¶
func CreateTopic(topic *ForumTopic, state *State) error
func CreateUser ¶
func CreateUserRelationship ¶
func CreateUserRelationship(relationship *Relationship, state *State) error
func DeleteForum ¶
func DeletePost ¶
func DeleteScore ¶
func DeleteTopic ¶
func DeleteTopic(topic *ForumTopic, state *State) error
func ExtractAudioSnippet ¶
func ExtractAudioSnippet(audioData []byte, offset int, duration int, bitrate int, storage Storage) ([]byte, error)
ExtractAudioSnippet extracts a snippet from the audio byte slice, compresses it, and saves it into an MP3 file
func FormatBytes ¶
FormatBytes returns a string representation of a byte slice similar to how python handles byte strings
func FormatStruct ¶
func FormatStruct(s interface{}) string
FormatStruct returns a string representation of a struct
func FormatValue ¶
FormatValue handles different types and returns the formatted string
func GetCountryClearsRank ¶
func GetCountryScoreRank ¶
func GetPasswordCache ¶
func GetSHA512Hash ¶
func HandlePanic ¶
func HandlePanic(err *error)
func JulianToTime ¶
JulianToTime converts a Julian date to time.Time
func ReadBigIntBE ¶
func RemoveBeatmap ¶
func RemoveBeatmapsBySetId ¶
func RemoveBeatmapset ¶
func RemoveBeatmapset(beatmapset *Beatmapset, state *State) error
func RemoveRankingsEntry ¶
func RemoveUserRelationship ¶
func RemoveUserRelationship(relationship *Relationship, state *State) error
func TimeToJulian ¶
TimeToJulian converts a time.Time object to Julian date
func UnpadPKCS7 ¶
func UpdateBeatmap ¶
func UpdateBeatmapset ¶
func UpdateBeatmapset(beatmapset *Beatmapset, state *State) error
func UpdateForum ¶
func UpdatePost ¶
func UpdateRankingsEntry ¶
func UpdateScore ¶
func UpdateStats ¶
func UpdateTopic ¶
func UpdateTopic(topic *ForumTopic, state *State) error
func WriteU16 ¶
func WriteU16[T constraints.Integer](value T) []byte
func WriteU16BE ¶
func WriteU16BE[T constraints.Integer](value T) []byte
func WriteU32 ¶
func WriteU32[T constraints.Integer](value T) []byte
func WriteU32BE ¶
func WriteU32BE[T constraints.Integer](value T) []byte
func WriteU64 ¶
func WriteU64[T constraints.Integer](value T) []byte
func WriteU64BE ¶
func WriteU64BE[T constraints.Integer](value T) []byte
func WriteU8 ¶
func WriteU8[T constraints.Integer](value T) []byte
Types ¶
type Beatmap ¶
type Beatmap struct {
Id int `gorm:"primaryKey;autoIncrement;not null"`
SetId int `gorm:"not null"`
Checksum string `gorm:"size:32;not null"`
Version string `gorm:"size:255;not null"`
Filename string `gorm:"size:512;not null"`
CreatorId int `gorm:"not null"`
CreatedAt time.Time `gorm:"not null;default:now()"`
LastUpdated time.Time `gorm:"not null;default:now()"`
Status BeatmapStatus `gorm:"not null"`
TotalLength int `gorm:"not null;default:0"`
DrainLength int `gorm:"not null;default:0"`
TotalCircles int `gorm:"not null;default:0"`
TotalSliders int `gorm:"not null;default:0"`
TotalSpinners int `gorm:"not null;default:0"`
TotalHolds int `gorm:"not null;default:0"`
MaxCombo int `gorm:"not null;default:0"`
MedianBpm float64 `gorm:"not null;default:0"`
HighestBpm float64 `gorm:"not null;default:0"`
LowestBpm float64 `gorm:"not null;default:0"`
CS float64 `gorm:"not null;default:0"`
HP float64 `gorm:"not null;default:0"`
OD float64 `gorm:"not null;default:0"`
AR float64 `gorm:"not null;default:0"`
SR float64 `gorm:"not null;default:0"`
Set Beatmapset `gorm:"foreignKey:SetId"`
Creator User `gorm:"foreignKey:CreatorId"`
}
func FetchBeatmapByChecksum ¶
func FetchBeatmapById ¶
func FetchBeatmapsBySetId ¶
func (*Beatmap) TotalObjects ¶
type BeatmapAvailability ¶
type BeatmapAvailability int
const ( BeatmapHasDownload BeatmapAvailability = iota BeatmapHasDMCA BeatmapAvailability = iota BeatmapHasInappropriateContent BeatmapAvailability = iota )
type BeatmapStatus ¶
type BeatmapStatus int
const ( BeatmapStatusUnknown BeatmapStatus = iota BeatmapStatusNotSubmitted BeatmapStatus = iota BeatmapStatusPending BeatmapStatus = iota BeatmapStatusRanked BeatmapStatus = iota BeatmapStatusApproved BeatmapStatus = iota )
type Beatmapset ¶
type Beatmapset struct {
Id int `gorm:"primaryKey;autoIncrement;not null"`
Title string `gorm:"size:255;not null"`
Artist string `gorm:"size:255;not null"`
Source string `gorm:"size:255;not null"`
Tags pq.StringArray `gorm:"type:text[];not null;default:'{}'"`
CreatorId int `gorm:"not null"`
CreatedAt time.Time `gorm:"not null;default:now()"`
LastUpdated time.Time `gorm:"not null;default:now()"`
ApprovedAt *time.Time `gorm:"default:null"`
ApprovedBy *int `gorm:"default:null"`
Status BeatmapStatus `gorm:"not null;default:1"`
Description string `gorm:"type:text;not null"`
HasVideo bool `gorm:"not null;default:false"`
AvailabilityStatus BeatmapAvailability `gorm:"not null;default:0"`
AvailabilityInfo string `gorm:"type:text;not null;default:''"`
TopicId *int `gorm:"default:null"`
Beatmaps []Beatmap `gorm:"foreignKey:SetId"`
Topic ForumTopic `gorm:"foreignKey:TopicId"`
Creator User `gorm:"foreignKey:CreatorId"`
}
func FetchBeatmapsetById ¶
func FetchBeatmapsetById(id int, state *State, preload ...string) (*Beatmapset, error)
func FetchBeatmapsetsByCreatorId ¶
func FetchBeatmapsetsByCreatorId(userId int, state *State, preload ...string) ([]Beatmapset, error)
func FetchBeatmapsetsByStatus ¶
func FetchBeatmapsetsByStatus(userId int, status BeatmapStatus, state *State, preload ...string) ([]Beatmapset, error)
type DatabaseConfiguration ¶
type DatabaseConfiguration struct {
Host string
Port int
Username string
Password string
Database string
MaxIdle int
MaxOpen int
MaxLifetime time.Duration
}
func (*DatabaseConfiguration) GetDSN ¶
func (config *DatabaseConfiguration) GetDSN() string
type ErrorCollection ¶
type ErrorCollection struct {
// contains filtered or unexported fields
}
func NewErrorCollection ¶
func NewErrorCollection() *ErrorCollection
func (*ErrorCollection) Add ¶
func (ec *ErrorCollection) Add(err error)
func (*ErrorCollection) Errors ¶
func (ec *ErrorCollection) Errors() []error
func (*ErrorCollection) HasErrors ¶
func (ec *ErrorCollection) HasErrors() bool
func (*ErrorCollection) Length ¶
func (ec *ErrorCollection) Length() int
func (*ErrorCollection) Next ¶
func (ec *ErrorCollection) Next() error
func (*ErrorCollection) Pop ¶
func (ec *ErrorCollection) Pop(index int) error
func (*ErrorCollection) String ¶
func (ec *ErrorCollection) String() string
type FileStorage ¶
type FileStorage struct {
// contains filtered or unexported fields
}
func (*FileStorage) CreateTempFile ¶
func (storage *FileStorage) CreateTempFile() (*os.File, error)
func (*FileStorage) DefaultAvatar ¶
func (storage *FileStorage) DefaultAvatar() ([]byte, error)
func (*FileStorage) Download ¶
func (storage *FileStorage) Download(url string, key string, folder string) error
func (*FileStorage) EnsureDefaultAvatar ¶
func (storage *FileStorage) EnsureDefaultAvatar() error
func (*FileStorage) GetBeatmapFile ¶
func (storage *FileStorage) GetBeatmapFile(beatmapId int) ([]byte, error)
func (*FileStorage) GetBeatmapPackage ¶
func (storage *FileStorage) GetBeatmapPackage(beatmapsetId int) ([]byte, error)
func (*FileStorage) GetBeatmapPreview ¶
func (storage *FileStorage) GetBeatmapPreview(beatmapId int) ([]byte, error)
func (*FileStorage) GetBeatmapThumbnail ¶
func (storage *FileStorage) GetBeatmapThumbnail(beatmapId int, large bool) ([]byte, error)
func (*FileStorage) GetReplayFile ¶
func (storage *FileStorage) GetReplayFile(scoreId int) ([]byte, error)
func (*FileStorage) Read ¶
func (storage *FileStorage) Read(key string, folder string) ([]byte, error)
func (*FileStorage) RemoveBeatmapFile ¶
func (storage *FileStorage) RemoveBeatmapFile(beatmapId int) error
func (*FileStorage) RemoveBeatmapPackage ¶
func (storage *FileStorage) RemoveBeatmapPackage(beatmapsetId int) error
func (*FileStorage) RemoveBeatmapPreview ¶
func (storage *FileStorage) RemoveBeatmapPreview(beatmapId int) error
func (*FileStorage) RemoveBeatmapThumbnail ¶
func (storage *FileStorage) RemoveBeatmapThumbnail(beatmapId int) error
func (*FileStorage) RemoveReplayFile ¶
func (storage *FileStorage) RemoveReplayFile(scoreId int) error
func (*FileStorage) Save ¶
func (storage *FileStorage) Save(key string, folder string, data []byte) error
func (*FileStorage) SaveAvatar ¶
func (storage *FileStorage) SaveAvatar(userId int, data []byte) error
func (*FileStorage) SaveBeatmapFile ¶
func (storage *FileStorage) SaveBeatmapFile(beatmapId int, data []byte) error
func (*FileStorage) SaveBeatmapPackage ¶
func (storage *FileStorage) SaveBeatmapPackage(beatmapsetId int, data []byte) error
func (*FileStorage) SaveBeatmapPreview ¶
func (storage *FileStorage) SaveBeatmapPreview(beatmapId int, data []byte) error
func (*FileStorage) SaveBeatmapThumbnail ¶
func (storage *FileStorage) SaveBeatmapThumbnail(beatmapId int, data []byte, large bool) error
func (*FileStorage) SaveReplayFile ¶
func (storage *FileStorage) SaveReplayFile(scoreId int, data []byte) error
type Forum ¶
type Forum struct {
Id int `gorm:"primaryKey;autoIncrement;not null"`
ParentId *int `gorm:"default:null"`
CreatedAt time.Time `gorm:"not null;default:now()"`
Name string `gorm:"size:32;not null"`
Description string `gorm:"size:255;not null;default:''"`
Hidden bool `gorm:"not null;default:false"`
Parent *Forum `gorm:"foreignKey:ParentId"`
}
type ForumPost ¶
type ForumPost struct {
Id int `gorm:"primaryKey;autoIncrement;not null"`
TopicId int `gorm:"not null"`
ForumId int `gorm:"not null"`
UserId int `gorm:"not null"`
Content string `gorm:"type:text;not null"`
CreatedAt time.Time `gorm:"not null;default:now()"`
EditTime time.Time `gorm:"not null;default:now()"`
EditCount int `gorm:"not null;default:0"`
EditLocked bool `gorm:"not null;default:false"`
Hidden bool `gorm:"not null;default:false"`
Deleted bool `gorm:"not null;default:false"`
Topic ForumTopic `gorm:"foreignKey:TopicId"`
Forum Forum `gorm:"foreignKey:ForumId"`
User User `gorm:"foreignKey:UserId"`
}
func FetchInitialPost ¶
type ForumTopic ¶
type ForumTopic struct {
Id int `gorm:"primaryKey;autoIncrement;not null"`
ForumId int `gorm:"not null"`
CreatorId int `gorm:"not null"`
Title string `gorm:"size:255;not null"`
StatusText *string `gorm:"size:255;default:null"`
CreatedAt time.Time `gorm:"not null;default:now()"`
LastPostAt time.Time `gorm:"not null;default:now()"`
LockedAt *time.Time `gorm:"default:null"`
Views int `gorm:"not null;default:0"`
Announcement bool `gorm:"not null;default:false"`
Hidden bool `gorm:"not null;default:false"`
Pinned bool `gorm:"not null;default:false"`
Forum Forum `gorm:"foreignKey:ForumId"`
Creator User `gorm:"foreignKey:CreatorId"`
}
func FetchTopicById ¶
func FetchTopicById(id int, state *State, preload ...string) (*ForumTopic, error)
type IOStream ¶
type IOStream struct {
// contains filtered or unexported fields
}
func (*IOStream) ReadDateTime ¶
func (*IOStream) ReadIntList ¶
func (*IOStream) ReadString ¶
func (*IOStream) ReadU32Bool ¶
func (*IOStream) WriteDateTime ¶
func (*IOStream) WriteIntList ¶
func (*IOStream) WriteString ¶
func (*IOStream) WriteU32Bool ¶
type Image ¶
type Image struct {
// Path is a path to an image.
Path string
// ContentType is the content type of the image.
ContentType string
// Data is the image data in a byte-array
Data []byte
// Size is the length of Data
Size int
// Current stores the existing image's dimensions
Current ImageDimensions
// Future store the new thumbnail dimensions.
Future ImageDimensions
}
An Image is an image and information about it.
type ImageDimensions ¶
type ImageDimensions struct {
// Width is the width of an image in pixels.
Width int
// Height is the height on an image in pixels.
Height int
// X is the right-most X-coordinate.
X int
// Y is the top-most Y-coordinate.
Y int
}
ImageDimensions stores dimensional information for an Image.
type ImageGenerator ¶
type ImageGenerator struct {
// Width is the destination thumbnail width.
Width int
// Height is the destination thumbnail height.
Height int
// DestinationPath is the destination thumbnail path.
DestinationPath string
// DestinationPrefix is the prefix for the destination thumbnail
// filename.
DestinationPrefix string
// Scaler is the scaler to be used when generating thumbnails.
Scaler string
}
ImageGenerator registers a generator configuration to be used when creating thumbnails.
func NewImageGenerator ¶
func NewImageGenerator(c ImageGenerator) *ImageGenerator
NewImageGenerator returns an instance of a thumbnail generator with a given configuration.
func (*ImageGenerator) CreateThumbnail ¶
func (gen *ImageGenerator) CreateThumbnail(i *Image) ([]byte, error)
CreateThumbnail generates a thumbnail.
func (*ImageGenerator) NewImageFromByteArray ¶
func (gen *ImageGenerator) NewImageFromByteArray(imageBytes []byte) (*Image, error)
NewImageFromByteArray reads in an image from a byte array and populates an Image object. That new Image object is returned along with any errors that occur during the operation.
func (*ImageGenerator) NewImageFromFile ¶
func (gen *ImageGenerator) NewImageFromFile(path string) (*Image, error)
NewImageFromFile reads in an image file from the file system and populates an Image object. That new Image object is returned along with any errors that occur during the operation.
type RedisConfiguration ¶
type Relationship ¶
type Relationship struct {
UserId int `gorm:"primaryKey;not null"`
TargetId int `gorm:"primaryKey;not null"`
Status RelationshipStatus `gorm:"type:relationship_status;not null"`
User User `gorm:"foreignKey:UserId"`
Target User `gorm:"foreignKey:TargetId"`
}
func FetchUserRelationship ¶
func FetchUserRelationships ¶
func FetchUserRelationships(userId int, status RelationshipStatus, state *State, preload ...string) ([]*Relationship, error)
type RelationshipStatus ¶
type RelationshipStatus string
const ( StatusFriend RelationshipStatus = "friend" StatusBlocked RelationshipStatus = "blocked" )
type ReplayData ¶
type ReplayData struct {
Header *ReplayHeader
Frames []*ReplayFrame
}
func ReadCompressedReplay ¶
func ReadCompressedReplay(stream *IOStream) (data *ReplayData, err error)
func ReadFullReplay ¶
func ReadFullReplay(stream *IOStream) (*ReplayData, error)
func (*ReplayData) Serialize ¶
func (replayData *ReplayData) Serialize(stream *IOStream)
func (*ReplayData) SerializeFrames ¶
func (replayData *ReplayData) SerializeFrames(stream *IOStream)
func (*ReplayData) String ¶
func (replayData *ReplayData) String() string
type ReplayFrame ¶
func ReadReplayFrame ¶
func ReadReplayFrame(stream *IOStream) *ReplayFrame
func (*ReplayFrame) Serialize ¶
func (frame *ReplayFrame) Serialize(stream *IOStream)
func (*ReplayFrame) String ¶
func (frame *ReplayFrame) String() string
type ReplayHeader ¶
type ReplayHeader struct {
Mode uint32
ReplayVersion uint8
BeatmapChecksum string
PlayerName string
ScoreChecksum string
Count300 uint32
Count100 uint32
Count50 uint32
CountGeki uint32
CountGood uint32
CountMiss uint32
TotalScore float64
MaxCombo uint32
FullCombo bool
Time time.Time
ModsData []byte
}
func ReadReplayHeader ¶
func ReadReplayHeader(stream *IOStream) *ReplayHeader
func (*ReplayHeader) Accuracy ¶
func (header *ReplayHeader) Accuracy() float64
func (*ReplayHeader) Grade ¶
func (header *ReplayHeader) Grade() Grade
func (*ReplayHeader) Serialize ¶
func (header *ReplayHeader) Serialize(stream *IOStream)
func (*ReplayHeader) String ¶
func (header *ReplayHeader) String() string
type Score ¶
type Score struct {
Id int `gorm:"primaryKey;autoIncrement;not null"`
BeatmapId int `gorm:"not null"`
UserId int `gorm:"not null"`
Checksum string `gorm:"size:32;not null"`
Status ScoreStatus `gorm:"not null"`
CreatedAt time.Time `gorm:"not null;default:now()"`
ClientVersion int `gorm:"not null"`
TotalScore int64 `gorm:"not null"`
MaxCombo int `gorm:"not null"`
Accuracy float64 `gorm:"not null"`
FullCombo bool `gorm:"not null"`
Passed bool `gorm:"not null"`
Grade Grade `gorm:"type:score_grade;not null"`
Count300 int `gorm:"not null;column:count_300"`
Count100 int `gorm:"not null;column:count_100"`
Count50 int `gorm:"not null;column:count_50"`
CountGeki int `gorm:"not null;column:count_geki"`
CountKatu int `gorm:"not null;column:count_katu"`
CountGood int `gorm:"not null;column:count_good"`
CountMiss int `gorm:"not null;column:count_miss"`
AROffset int `gorm:"not null"`
ODOffset int `gorm:"not null"`
CSOffset int `gorm:"not null"`
HPOffset int `gorm:"not null"`
PSOffset int `gorm:"not null"`
ModHidden bool `gorm:"not null"`
ModNoFail bool `gorm:"not null;column:mod_nofail"`
Visible bool `gorm:"not null;default:true"`
Pinned bool `gorm:"not null;default:false"`
Beatmap Beatmap `gorm:"foreignKey:BeatmapId"`
User User `gorm:"foreignKey:UserId"`
}
func FetchBestScores ¶
func FetchPersonalBest ¶
func FetchRangeScores ¶
type ScoreStatus ¶
type ScoreStatus int
const ( ScoreStatusUnranked ScoreStatus = iota ScoreStatusFailed ScoreStatus = iota ScoreStatusSubmitted ScoreStatus = iota ScoreStatusPB ScoreStatus = iota )
type State ¶
type State struct {
Database *gorm.DB
Redis *redis.Client
RedisContext *context.Context
Storage Storage
}
func NewState ¶
func NewState(config *StateConfiguration) (*State, error)
type StateConfiguration ¶
type StateConfiguration struct {
Database *DatabaseConfiguration
Redis *RedisConfiguration
DataPath string
}
func NewStateConfiguration ¶
func NewStateConfiguration() *StateConfiguration
type Stats ¶
type Stats struct {
UserId int `gorm:"primaryKey;not null"`
Rank int `gorm:"not null;default:0"`
TotalScore int64 `gorm:"not null;default:0"`
RankedScore int64 `gorm:"not null;default:0"`
Playcount int `gorm:"not null;default:0"`
Playtime int `gorm:"not null;default:0"`
Accuracy float64 `gorm:"not null;default:0.0000"`
MaxCombo int `gorm:"not null;default:0"`
TotalHits int64 `gorm:"not null;default:0"`
XHCount int `gorm:"not null;default:0"`
XCount int `gorm:"not null;default:0"`
SHCount int `gorm:"not null;default:0"`
SCount int `gorm:"not null;default:0"`
ACount int `gorm:"not null;default:0"`
BCount int `gorm:"not null;default:0"`
CCount int `gorm:"not null;default:0"`
DCount int `gorm:"not null;default:0"`
}
type Storage ¶
type Storage interface {
// Base
Save(key string, bucket string, data []byte) error
Read(key string, bucket string) ([]byte, error)
Remove(key string, bucket string) error
Download(url string, key string, bucket string) error
CreateTempFile() (*os.File, error)
// Replays
GetReplayFile(replayId int) ([]byte, error)
SaveReplayFile(replayId int, data []byte) error
RemoveReplayFile(replayId int) error
// Avatars
GetAvatar(userId int) ([]byte, error)
SaveAvatar(userId int, data []byte) error
DefaultAvatar() ([]byte, error)
EnsureDefaultAvatar() error
// Beatmaps
GetBeatmapFile(beatmapId int) ([]byte, error)
GetBeatmapPackage(beatmapsetId int) ([]byte, error)
GetBeatmapThumbnail(beatmapId int, large bool) ([]byte, error)
GetBeatmapPreview(beatmapId int) ([]byte, error)
SaveBeatmapFile(beatmapId int, data []byte) error
SaveBeatmapPackage(beatmapsetId int, data []byte) error
SaveBeatmapThumbnail(beatmapId int, data []byte, large bool) error
SaveBeatmapPreview(beatmapId int, data []byte) error
RemoveBeatmapFile(beatmapId int) error
RemoveBeatmapPackage(beatmapsetId int) error
RemoveBeatmapThumbnail(beatmapId int) error
RemoveBeatmapPreview(beatmapId int) error
}
func NewFileStorage ¶
type User ¶
type User struct {
Id int `gorm:"primaryKey;autoIncrement;not null"`
Name string `gorm:"size:32;not null"`
Email string `gorm:"size:255;not null"`
Password string `gorm:"size:60;not null"`
Country string `gorm:"size:2;default:'XX';not null"`
CreatedAt time.Time `gorm:"not null;default:now()"`
LatestActivity time.Time `gorm:"not null;default:now()"`
Restricted bool `gorm:"not null;default:false"`
Activated bool `gorm:"not null;default:false"`
Stats Stats `gorm:"foreignKey:UserId"`
}