models

package
v0.0.0-...-fecf105 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2014 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OT_GITHUB = iota + 1
	OT_BITBUCKET
	OT_OSCHINA
)

OT: Oauth2 Type

View Source
const (
	ST_READY      = "ready"
	ST_PENDING    = "pending"
	ST_RETRIEVING = "retrieving"
	ST_BUILDING   = "building"
	ST_PACKING    = "packing"
	ST_PUBLISHING = "publishing"
	ST_DONE       = "done"
	ST_ERROR      = "error"
)
View Source
const (
	AC_BUILD  = "action-build"
	AC_SRCPKG = "action-source-package"
)

Variables

View Source
var (
	ErrOauth2RecordNotExist = errors.New("OAuth2 record does not exist")
	ErrOauth2NotAssociated  = errors.New("OAuth2 is not associated with user")
)
View Source
var (
	ErrTaskNotAvaliable    = errors.New("not task ready for build now")
	ErrTaskNotExists       = errors.New("task not exists")
	ErrNoAvaliableDownload = errors.New("no avaliable download")
	ErrTaskIsRunning       = errors.New("task is running")
)
View Source
var (
	ErrRepositoryNotExists = errors.New("repo not found")
)
View Source
var GHClient *github.Client //= github.NewClient(httpClient)

Functions

func AddOauth2

func AddOauth2(oa *Oauth2) error

func BindUserOauth2

func BindUserOauth2(userId, oauthId int64) error

func CreateNewBuilding

func CreateNewBuilding(rid int64, branch string, os, arch string, action string) (err error)

func CreateTasks

func CreateTasks(tasks []*Task) error

func InitDB

func InitDB() (err error)

func RefreshPageView

func RefreshPageView(uri string, add ...int64) int64

func ResetAllTaskStatus

func ResetAllTaskStatus() error

func ResetTask

func ResetTask(tid int64) error

func UpdatePubAddr

func UpdatePubAddr(tid int64, pubAddr string) error

func UpdateRepository

func UpdateRepository(v *Repository, condi *Repository) (int64, error)

func UpdateTaskStatus

func UpdateTaskStatus(tid int64, status string, output string) error

Types

type BuildHistory

type BuildHistory struct {
	Id      int64
	Tid     int64  `xorm:"unique(b)"`
	Status  string `xorm:"unique(b)"`
	Output  string `xorm:"TEXT"`
	Updated string `xorm:"updated"`
}

going to clean

func GetAllBuildHistoryByTid

func GetAllBuildHistoryByTid(tid int64) ([]BuildHistory, error)

type DownloadHistory

type DownloadHistory struct {
	Id       int64
	Rid      int64
	Os       string
	Arch     string
	Ip       string
	CurrTime time.Time `xorm:"created"`
}

type LastRepoUpdate

type LastRepoUpdate struct {
	Rid        int64  `xorm:"unique(u)"`
	TagBranch  string `xorm:"unique(u)"`
	Os         string `xorm:"unique(u)"`
	Arch       string `xorm:"unique(u)"`
	PushURI    string
	ZipBallUrl string
	Updated    time.Time `xorm:"updated"`
}

func GetAllLastRepoByOsArch

func GetAllLastRepoByOsArch(os, arch string) (us []LastRepoUpdate, err error)

func GetAllLastRepoUpdate

func GetAllLastRepoUpdate(rid int64) (us []LastRepoUpdate, err error)

type Oauth2

type Oauth2 struct {
	Id  int64
	Uid int64 `xorm:"unique(s)"` // userId
	// User     *User  `xorm:"-"`
	Type     int    `xorm:"unique(s) unique(oauth)"` // twitter,github,google...
	Identity string `xorm:"unique(s) unique(oauth)"` // id..
	Token    string `xorm:"TEXT not null"`
}

func GetOauth2

func GetOauth2(identity string) (oa *Oauth2, err error)

func GetOauth2ById

func GetOauth2ById(id int64) (oa *Oauth2, err error)

func GetOauthByUserId

func GetOauthByUserId(uid int64) (oas []*Oauth2, err error)

GetOauthByUserId returns list of oauthes that are releated to given user.

type PageView

type PageView struct {
	Uri        string `xorm:"unique(pk)"`
	TotalCount int64
}

type RepoStatistic

type RepoStatistic struct {
	Rid           int64 `xorm:"pk"`
	Pv            int64
	DownloadCount int64
	Updated       time.Time `xorm:"updated"`
}

type Repository

type Repository struct {
	Id            int64
	Uri           string `xorm:"unique(r)"`
	Brief         string
	IsCgo         bool
	IsCmd         bool
	Tags          []string
	Created       time.Time `xorm:"created"`
	DownloadCount int64
}

func AddRepository

func AddRepository(repoName string) (r *Repository, err error)

func CreateRepository

func CreateRepository(r *Repository) (*Repository, error)

func GetAllRepos

func GetAllRepos(count, start int) ([]Repository, error)

func GetRepositoryById

func GetRepositoryById(id int64) (*Repository, error)

func GetRepositoryByName

func GetRepositoryByName(name string) (*Repository, error)

type Task

type Task struct {
	Id            int64
	Rid           int64       `xorm:"unique(t)"`
	Repo          *Repository `xorm:"-"`
	Action        string      `xorm:"unique(t)"` // build or package
	Os            string      `xorm:"unique(t)"`
	Arch          string      `xorm:"unique(t)"`
	CgoEnable     bool
	CommitMessage string
	ZipBallUrl    string

	TagBranch string
	PushType  string //`xorm:"unique(t)"` // branch|tag|commit // not support with xorm(20140606)
	PushValue string `xorm:"unique(t)"` //master|v1.2|45asf913

	Status  string
	Created time.Time `xorm:"created"`
	Updated time.Time `xorm:"updated"`
}

func CreateTask

func CreateTask(task *Task) (*Task, error)

func GetAvaliableTask

func GetAvaliableTask(os, arch string) (task *Task, err error)

func GetAvaliableTasks

func GetAvaliableTasks(os, arch string) (tasks []*Task, err error)

func GetOneDownloadableTask

func GetOneDownloadableTask(rid int64, os, arch string) (*Task, error)

func GetTaskById

func GetTaskById(tid int64) (*Task, error)

func GetTasksByRid

func GetTasksByRid(rid int64) ([]Task, error)

Jump to

Keyboard shortcuts

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