db

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2018 License: AGPL-3.0 Imports: 3 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddCategory

func AddCategory(db *sql.DB, category *Category) (err error)

AddCategory add category to db and fill Id

func AddFlag

func AddFlag(db *sql.DB, flag *Flag) (err error)

AddFlag add flag to db and fill id

func AddScore

func AddScore(db *sql.DB, score *Score) (err error)

AddScore add last result for team and fill id

func AddSession

func AddSession(db *sql.DB, s *Session) (err error)

AddSession add session and fill id

func AddTask

func AddTask(db *sql.DB, t *Task) (err error)

AddTask add task and fill id

func AddTeam

func AddTeam(db *sql.DB, t *Team) (err error)

AddTeam add team and fill id

func CleanDatabase

func CleanDatabase(db *sql.DB) (err error)

CleanDatabase clean all values and restart sequences in database without drop tables

func GetSessionCount

func GetSessionCount(db *sql.DB) (count int, err error)

GetSessionCount returns count of logged teams for all time

func GetSessionTeam

func GetSessionTeam(db *sql.DB, session string) (teamID int, err error)

GetSessionTeam get team id for session

func GetSolvedBy

func GetSolvedBy(db *sql.DB, taskID int) (teamIDs []int, err error)

GetSolvedBy get all team ids who solved task

func GetSolvedCount

func GetSolvedCount(db *sql.DB, taskID int) (count int, err error)

GetSolvedCount return amount of solved flags

func GetTeamIDByToken

func GetTeamIDByToken(db *sql.DB, token string) (teamID int, err error)

GetTeamIDByToken get team id by access token

func InitDatabase

func InitDatabase(path string) (db *sql.DB, err error)

InitDatabase recreate all database tables

func IsSolved

func IsSolved(db *sql.DB, teamID, taskID int) (solved bool, err error)

IsSolved return true if task solved by team

func OpenDatabase

func OpenDatabase(path string) (db *sql.DB, err error)

OpenDatabase need defer db.Close() after open

func SetOpened

func SetOpened(db *sql.DB, taskID int, opened bool) (err error)

SetOpened open or close task

func UpdateTask

func UpdateTask(db *sql.DB, t *Task) (err error)

UpdateTask update task

Types

type Category

type Category struct {
	ID   int
	Name string
}

Category row

func GetCategories

func GetCategories(db *sql.DB) (categories []Category, err error)

GetCategories get all categories in category table

type Flag

type Flag struct {
	ID        int
	TeamID    int
	TaskID    int
	Flag      string
	Solved    bool
	Timestamp time.Time
}

Flag row

func GetFlags

func GetFlags(db *sql.DB) (flags []Flag, err error)

GetFlags get all flags in flags table

type Score

type Score struct {
	ID        int
	TeamID    int
	Score     int
	Timestamp time.Time
}

Score row

func GetLastScore

func GetLastScore(db *sql.DB, teamID int) (s Score, err error)

GetLastScore get last result for team id

type Session

type Session struct {
	ID        int
	TeamID    int
	Session   string
	Timestamp time.Time
}

Session row

type Task

type Task struct {
	ID            int
	Name          string
	Desc          string
	NameEn        string
	DescEn        string
	Tags          string
	CategoryID    int
	Level         int
	ForceClosed   bool
	Price         int
	Shared        bool
	Flag          string
	MaxSharePrice int
	MinSharePrice int
	Opened        bool
	Author        string
	OpenedTime    time.Time
}

Task row

func GetTask

func GetTask(db *sql.DB, taskID int) (t Task, err error)

GetTask get task by id

func GetTasks

func GetTasks(db *sql.DB) (tasks []Task, err error)

GetTasks get all tasks in tasks table

type Team

type Team struct {
	ID    int
	Name  string
	Email string
	Desc  string
	Token string
	Test  bool
}

Team row

func GetTeams

func GetTeams(db *sql.DB) (teams []Team, err error)

GetTeams get all teams

Jump to

Keyboard shortcuts

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