Documentation
¶
Index ¶
- Variables
- func AddLog(db *gorm.DB, body string)
- func AddMime(db *gorm.DB, mime string) int
- func AddTagToFile(db *gorm.DB, tag string, fileId int, userId int)
- func CheckPasswordHash(password, hash string) bool
- func ConnectToMysql()
- func CreateCounter(name string) uint
- func CreateDevice(name string, userId uint) uint
- func CreateGroup(name string) uint
- func CreateProject(name string, groupId uint) uint
- func CreateTask(task Task)
- func CreateUser(username string, email string, password string)
- func DeviceEventAdd(code EventCode, userId uint, deviceId uint)
- func DeviceEventAddInt(code EventCode, userId uint, deviceId uint, val int)
- func DeviceEventAddStr(code EventCode, userId uint, deviceId uint, str string)
- func HashPassword(password string) (string, error)
- func ImportCountersFromJson(pathToFile string)
- func ImportZfire(pathToJson string)
- func InitMysql()
- func InitRedis()
- func IsInArray(list []string, name string) bool
- func IsInList(list []ZfireLogGameList, name string) bool
- func MigrateMysql()
- func PrettyTime(s uint) string
- func StartCounterSession(counterId uint, userId uint) uint
- func StopCounterSession(counterId uint, userId uint) (sessionId uint, sessionTaken string)
- func TaskDoneEvent(userId uint, taskId int)
- type Counter
- type CounterList
- func CounterStats(counterId, userId uint) (result []CounterList)
- func CountersLatestListAndroid(userId uint) (err error, result []CounterList)
- func CountersLongList(userId uint) (result []CounterList)
- func CountersLongListPaginate(userId uint, limit int, nextId int, prevId int, qTerm string) (result []CounterList, allRecords int)
- type CounterSession
- type CounterSessionList
- type CounterTag
- type Device
- type DeviceList
- type Event
- type EventCode
- type File
- type FileTag
- type FileTagList
- type FileUser
- type Group
- type Log
- type Mime
- type Note
- type NoteTag
- type Project
- type Tag
- type Task
- type TaskDoneT
- type TaskTabExport
- type TaskTabExportSession
- type TaskTabExports
- type User
- type WebhookAction
- type WebhookReceiver
- type ZfireGame
- type ZfireLog
- type ZfireLogGameList
Constants ¶
This section is empty.
Variables ¶
View Source
var ( DB *gorm.DB Redis *redis.Client AuthLimiter *redis_rate.Limiter )
Functions ¶
func CheckPasswordHash ¶
func ConnectToMysql ¶
func ConnectToMysql()
func CreateCounter ¶
func CreateDevice ¶
func CreateGroup ¶
func CreateProject ¶
func CreateTask ¶
func CreateTask(task Task)
func CreateUser ¶
func DeviceEventAdd ¶
func DeviceEventAddInt ¶
func DeviceEventAddStr ¶
func HashPassword ¶
func ImportCountersFromJson ¶
func ImportCountersFromJson(pathToFile string)
func ImportZfire ¶
func ImportZfire(pathToJson string)
func MigrateMysql ¶
func MigrateMysql()
func PrettyTime ¶
func StartCounterSession ¶
func StopCounterSession ¶
func TaskDoneEvent ¶
Types ¶
type Counter ¶
type Counter struct {
Id uint `json:"id" gorm:"primary_key;type:uint(10)" json:"id"`
Name string `gorm:"column:name" json:"username"`
ProjectId uint `gorm:"column:project_id" json:"group_id"`
CreatedAt *time.Time `gorm:"column:created_at" json:"created_at"`
UpdatedAt *time.Time `gorm:"column:updated_at" json:"updated_at"`
DeletedAt *time.Time `gorm:"column:deleted_at" json:"deleted_at"`
}
type CounterList ¶
type CounterList struct {
Counter
Tags string `json:"tags"`
Seconds7d uint `json:"secondsD7"`
Seconds30d uint `json:"secondsD30"`
SecondsAll uint `json:"secondsAll"`
Seconds7dFormatted string `json:"secondsD7F"`
Seconds30dFormatted string `json:"secondsD30F"`
SecondsAllFormatted string `json:"secondsAllF"`
Running uint `json:"running"`
}
func CounterStats ¶
func CounterStats(counterId, userId uint) (result []CounterList)
func CountersLatestListAndroid ¶
func CountersLatestListAndroid(userId uint) (err error, result []CounterList)
func CountersLongList ¶
func CountersLongList(userId uint) (result []CounterList)
type CounterSession ¶
type CounterSession struct {
Id uint `json:"id" gorm:"primary_key;type:uint(10)" json:"id"`
CounterId uint `gorm:"column:counter_id" json:"counter_id"`
UserId uint `gorm:"column:user_id" json:"user_id"`
StartedAt *time.Time `gorm:"column:started_at" json:"started_at"`
EndedAt *time.Time `gorm:"column:ended_at" json:"ended_at"`
Precise uint `gorm:"column:precise" json:"precise"`
CreatedAt *time.Time `gorm:"column:created_at" json:"created_at"`
UpdatedAt *time.Time `gorm:"column:updated_at" json:"updated_at"`
DeletedAt *time.Time `gorm:"column:deleted_at" json:"deleted_at"`
}
type CounterSessionList ¶
type CounterSessionList struct {
CounterId uint
Id uint
UserId uint
Name string
Tags string
StartedAt time.Time
EndedAt mysql.NullTime
Duration uint
DurationFormatted string
Running bool
}
func CounterLog ¶
func CounterLog(counterId int, userId uint, limit int) (result []CounterSessionList)
func CounterLogList ¶
func CounterLogList(userId uint, limit int) (result []CounterSessionList)
type CounterTag ¶
type CounterTag struct {
Id uint `json:"id" gorm:"primary_key;type:uint(10)" json:"id"`
CounterId uint `gorm:"column:counter_id" json:"counter_id"`
Name string `gorm:"column:name" json:"name"`
CreatedAt *time.Time `gorm:"column:created_at" json:"created_at"`
UpdatedAt *time.Time `gorm:"column:updated_at" json:"updated_at"`
DeletedAt *time.Time `gorm:"column:deleted_at" json:"deleted_at"`
}
type Device ¶
type Device struct {
Id uint `json:"id" gorm:"primary_key;type:uint(10)" json:"id"`
UserId uint `gorm:"column:user_id"`
Name string `gorm:"column:name"`
Token string `gorm:"token"`
TokenPush string `gorm:"token_push"`
CreatedAt *time.Time `gorm:"column:created_at" json:"created_at"`
UpdatedAt *time.Time `gorm:"column:updated_at" json:"updated_at"`
DeletedAt *time.Time `gorm:"column:deleted_at" json:"deleted_at"`
}
type DeviceList ¶
type DeviceList struct {
Id uint `json:"id"`
UserId uint `json:"userId"`
Name string `json:"name"`
CreatedAt time.Time `json:"createdAt"`
DisplayState string `json:"displayState"`
DisplayOnLastTime time.Time `json:"displayLastOn"`
DisplayOffLastTime time.Time `json:"displayLastOff"`
BatteryLeft uint `json:"battery"`
Username string `json:"username"`
MusicTrack string `json:"musicTrack"`
MusicArtist string `json:"musicArtist"`
MusicLastPlayed time.Time `json:"musicLastPlayed"`
}
func GetListOfDevices ¶
func GetListOfDevices() (result []DeviceList)
type Event ¶
type Event struct {
Id uint `json:"id" gorm:"primary_key;type:uint(10)" json:"id"`
UserId uint `gorm:"column:user_id"`
DeviceId uint `gorm:"column:device_id"`
Code EventCode `gorm:"column:code" json:"code"`
ValueStr sql.NullString `gorm:"column:val_str" json:"valStr"`
ValueInt sql.NullInt64 `gorm:"column:val_int"`
CreatedAt *time.Time `gorm:"column:created_at" json:"createdAt"`
}
type File ¶
type File struct {
Id int `gorm:"AUTO_INCREMENT" json:"id"`
Filename string `gorm:"column:file_name" json:"filename"`
FilePath string `gorm:"column:file_path;type:varchar(4096)" json:"filePath"`
SizeB int `gorm:"column:size_b" json:"sizeB"`
MimeId int `gorm:"column:mime_id" json:"-"`
PhashA int `gorm:"column:phash_a;type:bigint(16)" json:"-"`
PhashB int `gorm:"column:phash_b;type:bigint(16)" json:"-"`
PhashC int `gorm:"column:phash_c;type:bigint(16)" json:"-"`
PhashD int `gorm:"column:phash_d;type:bigint(16)" json:"-"`
Sha256 string `gorm:"column:sha256;type:char(64)" json:"sha256"`
CreatedAt *time.Time `gorm:"column:created_at" json:"created_at"`
UpdatedAt *time.Time `gorm:"column:updated_at" json:"updated_at"`
DeletedAt *time.Time `gorm:"column:deleted_at" json:"-"`
// helpers, not present in DB
Mime string `gorm:"-" json:"mime"`
Tags string `gorm:"-" json:"tags"`
Distance int `gorm:"-" json:"distance"`
}
func FileListPaginate ¶
func GetFileByIdForUser ¶
type FileTag ¶
type FileTag struct {
Id int `json:"id" gorm:"AUTO_INCREMENT" json:"id"`
UserId int `gorm:"column:user_id"`
FileId int `gorm:"column:file_id"`
TagId int `gorm:"column:tag_id"`
CreatedAt *time.Time `gorm:"column:created_at" json:"created_at"`
UpdatedAt *time.Time `gorm:"column:updated_at" json:"updated_at"`
DeletedAt *time.Time `gorm:"column:deleted_at" json:"deleted_at"`
}
type FileTagList ¶
func FileTagsList ¶
func FileTagsList(fileList []FileTagList, userId int) []FileTagList
TODO optimize, don't run it in loop
type FileUser ¶
type FileUser struct {
Id int `json:"id" gorm:"AUTO_INCREMENT" json:"id"`
FileId int `gorm:"column:file_id"`
UserId int `gorm:"column:user_id"`
CreatedAt *time.Time `gorm:"column:created_at" json:"created_at"`
UpdatedAt *time.Time `gorm:"column:updated_at" json:"updated_at"`
DeletedAt *time.Time `gorm:"column:deleted_at" json:"deleted_at"`
}
type Mime ¶
type Mime struct {
Id int `json:"id" gorm:"AUTO_INCREMENT" json:"id"`
Mime string `gorm:"column:mime"`
CreatedAt *time.Time `gorm:"column:created_at" json:"created_at"`
UpdatedAt *time.Time `gorm:"column:updated_at" json:"updated_at"`
DeletedAt *time.Time `gorm:"column:deleted_at" json:"deleted_at"`
}
type Note ¶
type Note struct {
Id uint `json:"id" gorm:"primary_key;type:uint(10)" json:"id"`
Title string `gorm:"column:title" json:"title"`
Body string `gorm:"column:body" json:"body"`
BodyShort string `gorm:"-"`
BodyMd template.HTML `gorm:"-"`
ProjectId uint `gorm:"column:project_id" json:"projectId"`
Tags string `gorm:"-"`
CreatedAt *time.Time `gorm:"column:created_at" json:"createdAt"`
UpdatedAt *time.Time `gorm:"column:updated_at" json:"updatedAt"`
DeletedAt *time.Time `gorm:"column:deleted_at" json:"deletedAt"`
}
func NoteLongList ¶
func NoteLongList() (result []Note)
type NoteTag ¶
type NoteTag struct {
Id uint `json:"id" gorm:"primary_key;type:uint(10)" json:"id"`
NoteId uint `gorm:"column:note_id" json:"note_id"`
Name string `gorm:"column:name" json:"name"`
CreatedAt *time.Time `gorm:"column:created_at" json:"created_at"`
UpdatedAt *time.Time `gorm:"column:updated_at" json:"updated_at"`
DeletedAt *time.Time `gorm:"column:deleted_at" json:"deleted_at"`
}
type Project ¶
type Project struct {
// ID
//
// required: true
Id uint `json:"id" gorm:"primary_key;type:uint(10)" json:"id"`
// Username
//
// required: true
Name string `gorm:"column:name" json:"name"`
GroupId uint `gorm:"column:group_id" json:"groupId"`
CreatedAt *time.Time `gorm:"column:created_at" json:"createdAt"`
UpdatedAt *time.Time `gorm:"column:updated_at" json:"updatedAt"`
DeletedAt *time.Time `gorm:"column:deleted_at" json:"deletedAt"`
}
Host represents the host for this application swagger:model user
type Tag ¶
type Tag struct {
Id int `json:"id" gorm:"AUTO_INCREMENT" json:"id"`
Tag string `gorm:"column:tag" json:"tag"`
CreatedAt *time.Time `gorm:"column:created_at" json:"created_at"`
UpdatedAt *time.Time `gorm:"column:updated_at" json:"updated_at"`
DeletedAt *time.Time `gorm:"column:deleted_at" json:"deleted_at"`
// not in table
Counter int `gorm:"-" json:"counter"`
}
type Task ¶
type Task struct {
Id uint `gorm:"primary_key;type:uint(10)" json:"id"`
Subject string `gorm:"column:subject" json:"subject"`
ProjectId uint `gorm:"column:project_id"`
AssignedUserId uint `gorm:"column:assigned_user_id"`
Repeating uint `gorm:"column:repeating"`
NeverEnding uint `gorm:"column:never_ending"`
RepeatUnit string `gorm:"column:repeat_unit"`
RepeatMin uint `gorm:"column:repeat_min"`
RepeatBest uint `gorm:"column:repeat_best"`
RepeatMax uint `gorm:"column:repeat_max"`
RepeatFrom *time.Time `gorm:"column:repeat_from"`
SnoozeTo *time.Time `gorm:"column:snooze_to"`
// RepeatFrom mysql.NullTime `gorm:"column:repeat_from"`
EstimateS uint `gorm:"column:estimate_s"`
MasterTaskId uint `gorm:"column:master_task_id"`
SeparateChildren uint `gorm:"column:separate_children"`
DoneAt *sql.NullTime `gorm:"column:done_at" json:"doneAt"`
CreatedAt *time.Time `gorm:"column:created_at" json:"created_at"`
UpdatedAt *time.Time `gorm:"column:updated_at" json:"updated_at"`
DeletedAt *time.Time `gorm:"column:deleted_at" json:"deleted_at"`
}
type TaskDoneT ¶
type TaskDoneT struct {
Subject string `json:"subject"`
Username string `json:"username"`
CreatedAt *time.Time `json:"createdAt"`
}
func TaskDoneEvents7days ¶
func TaskDoneEvents7days() (result []TaskDoneT)
type TaskTabExport ¶
type TaskTabExport struct {
Name string `json:"name"`
CreatedAt time.Time `json:"createdAt"`
Tags []string `json:"tags"`
ZfireTimeSumS uint `json:"zfireTimeSummaryS"`
TaskTabTimeSumS uint `json:"taskTabTimeSummaryS"`
ZfireTimeSumP uint `json:"zfireTimeSummaryP"`
TaskTabTimeSumP uint `json:"taskTabTimeSummaryP"`
SessionsS TaskTabExportSession `json:"sessionsS"`
SessionsP TaskTabExportSession `json:"sessionsP"`
}
final export json
type TaskTabExportSession ¶
type TaskTabExportSession []struct {
Duration int
StartedAt time.Time
EndedAt time.Time
Precise uint
}
func (TaskTabExportSession) Len ¶
func (a TaskTabExportSession) Len() int
func (TaskTabExportSession) Less ¶
func (a TaskTabExportSession) Less(i, j int) bool
func (TaskTabExportSession) Swap ¶
func (a TaskTabExportSession) Swap(i, j int)
type TaskTabExports ¶
type TaskTabExports []TaskTabExport
func (TaskTabExports) Len ¶
func (a TaskTabExports) Len() int
func (TaskTabExports) Less ¶
func (a TaskTabExports) Less(i, j int) bool
func (TaskTabExports) Swap ¶
func (a TaskTabExports) Swap(i, j int)
type User ¶
type User struct {
// ID
//
// required: true
Id uint `json:"id" gorm:"primary_key;type:uint(10)" json:"id"`
// Username
//
// required: true
Username string `gorm:"column:username" json:"username"`
Email string `gorm:"column:email" json:"email"`
Hash string `gorm:"column:hash" json:"hash"`
DefaultProjectId uint `gorm:"column:default_project_id"`
CreatedAt *time.Time `gorm:"column:created_at" json:"created_at"`
UpdatedAt *time.Time `gorm:"column:updated_at" json:"updated_at"`
}
Host represents the host for this application swagger:model user
func GetUserById ¶
type WebhookAction ¶
type WebhookAction struct {
Id uint `json:"id" gorm:"primary_key;type:uint(10)" json:"id"`
Extra string `gorm:"column:extra"`
Type uint `gorm:"column:type"`
CreatedAt *time.Time `gorm:"column:created_at" json:"created_at"`
UpdatedAt *time.Time `gorm:"column:updated_at" json:"updated_at"`
DeletedAt *time.Time `gorm:"column:deleted_at" json:"deleted_at"`
}
type WebhookReceiver ¶
type WebhookReceiver struct {
Id uint `json:"id" gorm:"primary_key;type:uint(10)" json:"id"`
ProjectId uint `gorm:"column:project_id"`
ActionId uint `gorm:"column:action_id"`
CreatedAt *time.Time `gorm:"column:created_at" json:"created_at"`
UpdatedAt *time.Time `gorm:"column:updated_at" json:"updated_at"`
DeletedAt *time.Time `gorm:"column:deleted_at" json:"deleted_at"`
}
type ZfireGame ¶
type ZfireGame []struct {
Date time.Time `json:"date"`
Name string `json:"name"`
TimeP int `json:"time_p"`
TimeS int `json:"time_s"`
Tags []string `json:"tags"`
}
store complete game list with game time summary
type ZfireLog ¶
type ZfireLog []struct {
Name string `json:"name"`
TimeP int `json:"time_p"`
TimeS int `json:"time_s"`
Date time.Time `json:"date"`
}
store game sessions this log doesn't have entries pre 2012-10-03 - instead it's counted in time_p and time_s as a summary
type ZfireLogGameList ¶
temp local store
Click to show internal directories.
Click to hide internal directories.