models

package
v0.0.0-...-cd27406 Latest Latest
Warning

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

Go to latest
Published: May 25, 2014 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package models implemented database access funtions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteProject

func DeleteProject(path string)

DeleteProject deletes everything of the package, and update import information.

func FlushCacheProjects

func FlushCacheProjects(pinfos []hv.PkgInfo)

FlushCacheProjects saves cache data to database.

func GetGoRepo

func GetGoRepo() (pinfos []*hv.PkgInfo)

GetGoRepo returns packages in go standard library.

func GetGoSubrepo

func GetGoSubrepo() (pinfos []*hv.PkgInfo)

func GetGroupPkgInfo

func GetGroupPkgInfo(paths []string) []*hv.PkgInfo

GetGroupPkgInfo returns group of package infomration in order to reduce database connect times.

func GetGroupPkgInfoById

func GetGroupPkgInfoById(pids []string) []*hv.PkgInfo

GetGroupPkgInfoById returns group of package infomration by pid.

func GetImports

func GetImports(spid, tag string) []*hv.PkgInfo

func GetIndexPkgs

func GetIndexPkgs(page int) (pkgs []hv.PkgInfo)

GetIndexPkgs returns package information in given page.

func GetIndexStats

func GetIndexStats() (int64, int64, int64)

GetIndexStats returns index page statistic information.

func GetPkgInfo

func GetPkgInfo(path, tag string) (*hv.PkgInfo, error)

GetPkgInfo returns 'PkgInfo' by given import path and tag. It returns error when the package does not exist.

func GetPkgInfoById

func GetPkgInfoById(pid int) (pinfo *hv.PkgInfo, err error)

GetPkgInfoById returns package information from database by pid.

func GetRefs

func GetRefs(spid string) []*hv.PkgInfo

func GetSubPkgs

func GetSubPkgs(importPath, tag string, dirs []string) []hv.PkgInfo

GetSubPkgs returns sub-projects by given sub-directories.

func InitDb

func InitDb()

InitDb initializes the database.

func SavePkgExam

func SavePkgExam(gist *PkgExam) error

SavePkgExam saves user examples.

func SaveProject

func SaveProject(pinfo *hv.PkgInfo, pdecl *PkgDecl, pfuncs []PkgFunc, imports []string) error

SaveProject saves package information, declaration and functions; update import information.

func SearchPkg

func SearchPkg(key string, isCmd, isCgo, isGoRepo, isGoSubrepo int, isSynopsis bool) (pinfos []hv.PkgInfo)

SearchPkg returns packages that import path and synopsis contains keyword. 0 = false, 1 = true, other = undefined

Types

type PkgDecl

type PkgDecl struct {
	Id  int64
	Pid int64  `xorm:"unique(pkg_decl_pid_tag) index"`
	Tag string `xorm:"unique(pkg_decl_pid_tag) VARCHAR(50)"`

	// Indicate how many JS should be downloaded(JsNum=total num - 1)
	JsNum       int
	IsHasExport bool

	// Top-level declarations.
	IsHasConst, IsHasVar bool

	IsHasExample bool

	Imports, TestImports string `xorm:"TEXT"`

	IsHasFile   bool
	IsHasSubdir bool
}

PkgDecl is package declaration in database acceptable form.

func LoadProject

func LoadProject(pid int64, tag string) (*PkgDecl, error)

LoadProject returns package declaration.

type PkgExam

type PkgExam struct {
	Id       int64
	Path     string    `xorm:"index VARCHAR(150)"`
	Gist     string    `xorm:"VARCHAR(150)"` // Gist path.
	Examples string    `xorm:"TEXT"`         // Examples.
	Created  time.Time `xorm:"index"`
}

A PkgExam descriables the user example of the project.

func GetAllExams

func GetAllExams() (pkgExams []PkgExam, err error)

GetAllExams returns all user examples.

func GetPkgExams

func GetPkgExams(path string) (pkgExams []PkgExam, err error)

GetPkgExams returns user examples.

func GetPopulars

func GetPopulars(proNum, exNum int) (error, []*PkgExam, []*hv.PkgInfo, []*hv.PkgInfo, []*hv.PkgInfo, []*hv.PkgInfo)

GetPopulars returns <num>

  1. Recent viewed
  2. Top rank
  3. Top viewed
  4. Rock this week

projects and recent updated examples.

type PkgFunc

type PkgFunc struct {
	Id    int64
	Pid   int64  `xorm:"index"` // Id of package documentation it belongs to.
	Path  string `xorm:"VARCHAR(150)"`
	Name  string `xorm:"index VARCHAR(100)"`
	Doc   string `xorm:"TEXT"`
	IsOld bool   // Indicates if the function no longer exists.
}

PkgFunc represents a package function.

func SearchFunc

func SearchFunc(key string) (pfuncs []PkgFunc)

SearchFunc returns functions that name contains keyword.

type PkgImport

type PkgImport struct {
	Id      int64
	Path    string `xorm:"index VARCHAR(150)"`
	Imports string `xorm:"TEXT"`
}

PkgImport represents a package imports record.

type PkgRock

type PkgRock struct {
	Id    int64
	Pid   int64  `xorm:"index"`
	Path  string `xorm:"VARCHAR(150)"`
	Rank  int64
	Delta int64 `xorm:"index"`
}

A PkgRock descriables the trending rank of the project.

type PkgTag

type PkgTag struct {
	Id   int64
	Path string `xorm:"unique(pkg_tag_path_tag) index VARCHAR(150)"`
	Tag  string `xorm:"unique(pkg_tag_path_tag) VARCHAR(50)"`
	Vcs  string `xorm:"VARCHAR(50)"`
	Tags string `xorm:"TEXT"`
}

A PkgTag descriables the project revision tag for its sub-projects, any project that has this record means it's passed check of Go project, and do not need to download whole project archive when refresh.

Jump to

Keyboard shortcuts

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