models

package
v0.0.0-...-de6101d Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2019 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const PackageVersion = 1

PackageVersion is modified when previously stored packages are invalid.

Variables

View Source
var (
	ErrEmptyPackagePath     = errors.New("package import path is empty")
	ErrPackageNotFound      = errors.New("package does not found")
	ErrPackageVersionTooOld = errors.New("package version is too old")
)
View Source
var ErrJSFileNotFound = errors.New("JS file does not exist")

Functions

func ComposeSpacesObjectNames

func ComposeSpacesObjectNames(importPath, etag string, numExtraFiles int) []string

func DeletePackageByPath

func DeletePackageByPath(importPath string) error

func DistributeJSFiles

func DistributeJSFiles()

DistributeJSFiles uploads local JS files to DigitalOcean Spaces.

func NumDailyActivePackages

func NumDailyActivePackages() int64

func NumDistributedJSFiles

func NumDistributedJSFiles() int64

func NumGeneratedJSFiles

func NumGeneratedJSFiles() int64

func NumMonthlyActivePackages

func NumMonthlyActivePackages() int64

func NumRecycledJSFiles

func NumRecycledJSFiles() int64

func NumTotalJSFiles

func NumTotalJSFiles() int64

func NumTotalPackages

func NumTotalPackages() int64

func NumWeeklyActivePackages

func NumWeeklyActivePackages() int64

func RecycleJSFiles

func RecycleJSFiles()

RecycleJSFiles deletes local or distributed JS files due to inactive status.

func RefreshNumTotalPackages

func RefreshNumTotalPackages()

func SaveJSFile

func SaveJSFile(jsFile *JSFile) error

SaveJSFile inserts or updates JSFile record with given etag.

func SavePkgInfo

func SavePkgInfo(pinfo *PkgInfo, updateRefs bool) (err error)

SavePkgInfo saves package information.

Types

type JSFile

type JSFile struct {
	ID            int64
	PkgID         int64  `xorm:"INDEX UNIQUE(pkg_id_etag)"`
	Etag          string `xorm:"UNIQUE(pkg_id_etag)"`
	Status        JSFileStatus
	NumExtraFiles int // Indicates the number of extra JS files generated
}

func GetJSFile

func GetJSFile(pkgID int64, etag string) (*JSFile, error)

type JSFileStatus

type JSFileStatus int
const (
	JSFileStatusNone JSFileStatus = iota
	JSFileStatusGenerated
	JSFileStatusDistributed
	JSFileStatusRecycled
)

type PkgInfo

type PkgInfo struct {
	ID         int64
	Name       string `xorm:"-"`
	ImportPath string `xorm:"UNIQUE"`
	Etag       string

	ProjectPath string
	ViewDirPath string
	Synopsis    string

	IsCmd       bool
	IsCgo       bool
	IsGoRepo    bool
	IsGoSubrepo bool
	IsGaeRepo   bool

	PkgVer int

	Priority int `xorm:" NOT NULL"`
	Views    int64
	Stars    int64

	ImportNum int64
	ImportIDs string `xorm:"import_ids LONGTEXT"`
	// Import num usually is small so save it to reduce a database query.
	ImportPaths string `xorm:"LONGTEXT"`

	RefNum int64
	RefIDs string `xorm:"ref_ids LONGTEXT"`

	Subdirs string `xorm:"TEXT"`

	LastViewed int64 `xorm:"NOT NULL DEFAULT 0"`
	Created    int64

	JSFile *JSFile `xorm:"-"`
}

PkgInfo represents the package information.

func GetGAERepos

func GetGAERepos() ([]*PkgInfo, error)

func GetGoRepos

func GetGoRepos() ([]*PkgInfo, error)

func GetGoSubepos

func GetGoSubepos() ([]*PkgInfo, error)

func GetPkgInfo

func GetPkgInfo(importPath string) (*PkgInfo, error)

GetPkgInfo returns package information by given import path.

func GetPkgInfoByID

func GetPkgInfoByID(id int64) (*PkgInfo, error)

GetPkgInfoByID returns package information by given ID.

func GetPkgInfosByIDs

func GetPkgInfosByIDs(ids []int64) ([]*PkgInfo, error)

GetPkgInfosByIDs returns a list of package info by given IDs.

func GetPkgInfosByPaths

func GetPkgInfosByPaths(paths []string) []*PkgInfo

GetPkgInfosByPaths returns a list of packages by given import paths.

func GetSubPkgs

func GetSubPkgs(importPath string, dirs []string) []*PkgInfo

GetSubPkgs returns sub-projects by given sub-directories.

func SearchPkgInfo

func SearchPkgInfo(limit int, keyword string) ([]*PkgInfo, error)

SearchPkgInfo searches package information by given keyword.

func (*PkgInfo) CanRefresh

func (p *PkgInfo) CanRefresh() bool

CanRefresh returns true if package is available to refresh.

func (*PkgInfo) GetRefs

func (p *PkgInfo) GetRefs() []*PkgInfo

GetRefs returns a list of packages that import this one.

func (*PkgInfo) HasJSFile

func (p *PkgInfo) HasJSFile() bool

HasJSFile returns false if JS file must be regenerated, it populates the JSFile field when file exists.

func (*PkgInfo) LocalJSPath

func (p *PkgInfo) LocalJSPath() string

func (*PkgInfo) LocalJSPaths

func (p *PkgInfo) LocalJSPaths() []string

type PkgRef

type PkgRef struct {
	ID         int64
	ImportPath string `xorm:"UNIQUE"`
	RefNum     int64
	RefIDs     string `xorm:"ref_ids LONGTEXT"`
}

PkgRef represents temporary reference information of a package.

Jump to

Keyboard shortcuts

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