models

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2019 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DATA_TYPE string
	DATA_HOST string
	DATA_PORT int
	DATA_NAME string
	USERNAME  string
	PASSWORD  string
	SSL_MODE  string
	DATA_PATH string

	Engine *xorm.Engine
)

Functions

func Auth

func Auth(username, password string) (bool, string, error)

func CancelReportById

func CancelReportById(id int64) (page int, err error)

func CancelReportsByRepo

func CancelReportsByRepo(id int64) (err error)

func ChangeReportsStatusByRepo

func ChangeReportsStatusByRepo(id int64, status int) (err error)

func ConfirmAppResult

func ConfirmAppResult(id int64) (err error)

func ConfirmResultById

func ConfirmResultById(id int64) (err error)

confirm the whole repository by id

func ConvertRuleType

func ConvertRuleType(id int64) (err error)

func DeleteAdminById

func DeleteAdminById(id int64) error

func DeleteAllInputInfo

func DeleteAllInputInfo() error

func DeleteAllRepos

func DeleteAllRepos() error

func DeleteFilterRuleById

func DeleteFilterRuleById(id int64) (err error)

func DeleteInputInfoById

func DeleteInputInfoById(id int64) error

func DeleteRulesById

func DeleteRulesById(id int64) (err error)

func DeleteTokenById

func DeleteTokenById(id int64) error

func DisableRepoById

func DisableRepoById(id int64) error

func DisableRepoByUrl

func DisableRepoByUrl(repoUrl string) error

func DisableRulesById

func DisableRulesById(id int64) (err error)

func EditAdminById

func EditAdminById(id int64, username, password, role string) error

func EditFilterRuleById

func EditFilterRuleById(id int64, ruleType int, ruleKey, ruleValue string) error

func EditInputInfoById

func EditInputInfoById(id int64, inputType, content, desc string) error

func EditRuleById

func EditRuleById(id int64, position, ruleType, pat, caption, desc string, status int) error

func EditTokenById

func EditTokenById(id int64, token, desc string) error

func EnableRepoById

func EnableRepoById(id int64) error

func EnableRulesById

func EnableRulesById(id int64) (err error)

func GetPageById

func GetPageById(id int64) (int, error)

func IgnoreAppSearchResult

func IgnoreAppSearchResult(id int64) (err error)

func InitAdmin

func InitAdmin()

func InitRules

func InitRules()

func InsertBlacklistRules

func InsertBlacklistRules(filename string) error

func InsertRules

func InsertRules(filename string) error

func NewDbEngine

func NewDbEngine() (err error)

init a database instance

func UpdateRate

func UpdateRate(token string, response *github.Response) error

Types

type Admin

type Admin struct {
	Id       int64
	Username string
	Password string
	Role     string
}

func GetAdminById

func GetAdminById(id int64) (*Admin, bool, error)

func ListAdmins

func ListAdmins() ([]Admin, error)

func NewAdmin

func NewAdmin(username, password, role string) *Admin

func (*Admin) Insert

func (u *Admin) Insert() (int64, error)

type AppSearchResult

type AppSearchResult struct {
	Id          int64
	Name        *string `json:"name,omitempty"`
	Description *string
	Market      *string `json:"market,omitempty"`
	Developer   *string
	Version     *string
	DeployDate  *string
	AppUrl      *string
	Status      int
	CreatedTime time.Time `xorm:"created"`
	UpdatedTime time.Time `xorm:"updated"`
}

AppSearchResult represents a single search result for app market search

func ListAppSearchResultByPage

func ListAppSearchResultByPage(page int, status int) ([]AppSearchResult, int, int)

func (*AppSearchResult) Exist

func (r *AppSearchResult) Exist() (bool, error)

func (*AppSearchResult) Insert

func (r *AppSearchResult) Insert() (int64, error)

type CodeResult

type CodeResult struct {
	Id          int64
	Name        *string `json:"name,omitempty"`
	Path        *string `json:"path,omitempty"`
	RepoName    string
	SHA         *string            `json:"sha,omitempty" xorm:"sha"`
	HTMLURL     *string            `json:"html_url,omitempty" xorm:"html_url"`
	Repository  *github.Repository `json:"repository,omitempty" xorm:"json"`
	TextMatches []TextMatch        `json:"text_matches,omitempty" xorm:"LONGBLOB"`
	Status      int                // 1 confirmed 2 ignored
	Version     int                `xorm:"version"`
	CreatedTime time.Time          `xorm:"created"`
	UpdatedTime time.Time          `xorm:"updated"`
	RepoPath    *string
	Keyword     *string
	Score       float32
}

CodeResult represents a single search result.

func GetReportById

func GetReportById(id int64, omitRepo bool) (bool, *CodeResult, error)

func ListGithubSearchResultPage

func ListGithubSearchResultPage(page int, status int) ([]CodeResult, int, int)

func (*CodeResult) Exist

func (r *CodeResult) Exist() (bool, error)

func (*CodeResult) Insert

func (r *CodeResult) Insert() (int64, error)

type CodeResultDetail

type CodeResultDetail struct {
	Id int64
	// owner
	OwnerName      *string
	OwnerURl       *string
	Company        *string
	Location       *string
	Email          *string
	Blog           *string
	OwnerCreatedAt string
	Type           *string
	// repo
	RepoName      *string
	RepoUrl       *string
	Lang          *string
	Keyword       *string
	RepoCreatedAt *github.Timestamp
	RepoUpdatedAt *github.Timestamp

	Status       int
	MatchedTexts []TextMatch
}

func GetCodeResultDetailById

func GetCodeResultDetailById(id int64) (*CodeResultDetail, error)

type CodeSearchResult

type CodeSearchResult struct {
	Total             *int         `json:"total_count,omitempty"`
	IncompleteResults *bool        `json:"incomplete_results,omitempty"`
	CodeResults       []CodeResult `json:"items,omitempty" xorm:"json"`
}

CodeSearchResult represents the result of a code search.

type FilterRule

type FilterRule struct {
	Id        int64
	RuleType  int // 0: blacklist rule, 1: whitelist rule
	RuleKey   string
	RuleValue string `xorm:"text"`
}

func GetFilterRuleById

func GetFilterRuleById(id int64) (*FilterRule, bool, error)

func GetFilterRules

func GetFilterRules() ([]FilterRule, error)

func GetFilterRulesPage

func GetFilterRulesPage(page int) ([]FilterRule, int, error)

func LoadBlackListRuleFromFile

func LoadBlackListRuleFromFile(filename string) ([]FilterRule, error)

func NewFilterRule

func NewFilterRule(ruleType int, ruleKey, ruleValue string) *FilterRule

func (*FilterRule) Insert

func (r *FilterRule) Insert() (err error)

type GithubToken

type GithubToken struct {
	Id    int64
	Token string
	Desc  string
	// The number of requests per hour the client is currently limited to.
	Limit int `json:"limit"`
	// The number of remaining requests the client can make this hour.
	Remaining int `xorm:"default 5000 notnull" json:"remaining"`
	// The time at which the current rate limit will reset.
	Reset time.Time `json:"reset"`
}

func GetTokenById

func GetTokenById(id int64) (*GithubToken, bool, error)

func ListTokens

func ListTokens() ([]GithubToken, error)

func ListValidTokens

func ListValidTokens() ([]GithubToken, error)

func NewGithubToken

func NewGithubToken(token, desc string) *GithubToken

create a GithubToken with limit and remain

func (*GithubToken) Exist

func (g *GithubToken) Exist() (bool, error)

detect if the GithubToken exists

func (*GithubToken) Insert

func (g *GithubToken) Insert() (int64, error)

insert a GithubToken into database

type InputInfo

type InputInfo struct {
	Id          int64
	Type        string    `xorm:"varchar(255) notnull"`
	Content     string    `xorm:"text notnull"`
	Desc        string    `xorm:"text notnull"`
	Developer   string    `xorm:"text"`
	Version     int       `xorm:"version"`
	CreatedTime time.Time `xorm:"created"`
	UpdatedTime time.Time `xorm:"updated"`
}

func GetInputInfoById

func GetInputInfoById(id int64) (*InputInfo, bool, error)

func ListInputInfo

func ListInputInfo() ([]InputInfo, error)

func ListInputInfoPage

func ListInputInfoPage(page int) ([]InputInfo, int, error)

func NewInputInfo

func NewInputInfo(inputType, content, desc string) (info *InputInfo)

func (*InputInfo) Exist

func (i *InputInfo) Exist(repoUrl string) (bool, error)

func (*InputInfo) Insert

func (i *InputInfo) Insert() (int64, error)

type Match

type Match struct {
	Id      int64
	Text    *string `json:"text,omitempty" xorm:"LONGBLOB"`
	Indices []int   `json:"indices,omitempty" xorm:"json"`
}

type MatchedText

type MatchedText struct {
	Keyword    *string
	StartIndex int
	EndIndex   int
	Text       *string
}

type Repo

type Repo struct {
	Id     int64
	Name   string
	Url    string
	Status int `xorm:"int notnull default(1)"`
}

func ListEnableRepos

func ListEnableRepos() ([]Repo, error)

func ListReposPage

func ListReposPage(page int) ([]Repo, int, error)

func NewRepo

func NewRepo(name, repoUrl string) (repo *Repo)

func (*Repo) Exist

func (r *Repo) Exist() (bool, error)

func (*Repo) Insert

func (r *Repo) Insert() (int64, error)

type Rule

type Rule struct {
	Id          int64
	Position    string
	Type        string
	Pattern     string
	Caption     string
	Description string `xorm:"text"`
	Status      int    `xorm:"int default 0 notnull"`
}

func GetRuleById

func GetRuleById(id int64) (*Rule, bool, error)

func GetRules

func GetRules() ([]Rule, error)

func GetRulesPage

func GetRulesPage(page int) ([]Rule, int, error)

func GetValidRules

func GetValidRules() ([]Rule, error)

func GetValidRulesByType

func GetValidRulesByType(Type string) ([]Rule, error)

func LoadRuleFromFile

func LoadRuleFromFile(filename string) ([]Rule, error)

func NewRule

func NewRule(ruleType, pat, caption, pos, desc string, status int) *Rule

func (*Rule) Insert

func (r *Rule) Insert() (err error)

type TextMatch

type TextMatch struct {
	Id         int64
	ObjectURL  *string `json:"object_url,omitempty"`
	ObjectType *string `json:"object_type,omitempty"`
	Property   *string `json:"property,omitempty"`
	Fragment   *string `json:"fragment,omitempty"`
	Matches    []Match `xorm:"LONGBLOB"`
}

TextMatch represents a text match for a SearchResult

func GetMatchedTexts

func GetMatchedTexts(repoName string) []TextMatch

Jump to

Keyboard shortcuts

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