model

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2016 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateOrUpdateStar

func CreateOrUpdateStar(db *gorm.DB, star *Star, service *Service) (bool, error)

CreateOrUpdateStar creates or updates a star and returns true if the star was created (vs updated)

func FindLanguages

func FindLanguages(db *gorm.DB) ([]string, error)

FindLanguages finds all languages

func InitDB

func InitDB(filepath string, verbose bool) (*gorm.DB, error)

InitDB initializes the database at the specified path

func InitIndex added in v0.2.0

func InitIndex(filepath string) (bleve.Index, error)

InitIndex initializes the search index at the specified path

Types

type Service

type Service struct {
	gorm.Model
	Name  string
	Stars []Star
}

Service represents a hosting service like Github

func FindOrCreateServiceByName

func FindOrCreateServiceByName(db *gorm.DB, name string) (*Service, bool, error)

FindOrCreateServiceByName returns a service with the specified name, creating if necessary

type Star

type Star struct {
	gorm.Model
	RemoteID    string
	Name        *string
	FullName    *string
	Description *string
	Homepage    *string
	URL         *string
	Language    *string
	Stargazers  int
	StarredAt   time.Time
	ServiceID   uint
	Tags        []Tag `gorm:"many2many:star_tags;"`
}

Star represents a starred repository

func FindStarByID added in v0.2.0

func FindStarByID(db *gorm.DB, ID uint) (*Star, error)

FindStarByID finds a star by ID

func FindStars

func FindStars(db *gorm.DB, match string) ([]Star, error)

FindStars finds all stars

func FindStarsByLanguage

func FindStarsByLanguage(db *gorm.DB, match string, language string) ([]Star, error)

FindStarsByLanguage finds stars with the specified language

func FindStarsByLanguageAndOrTag added in v0.4.0

func FindStarsByLanguageAndOrTag(db *gorm.DB, match string, language string, tagName string, union bool) ([]Star, error)

FindStarsByLanguageAndOrTag finds stars with the specified language and/or the specified tag

func FindUntaggedStars added in v0.4.0

func FindUntaggedStars(db *gorm.DB, match string) ([]Star, error)

FindUntaggedStars finds stars without any tags

func FuzzyFindStarsByName

func FuzzyFindStarsByName(db *gorm.DB, name string) ([]Star, error)

FuzzyFindStarsByName finds stars with approximate matching for full name and name

func NewStarFromGithub

func NewStarFromGithub(timestamp *github.Timestamp, star github.Repository) (*Star, error)

NewStarFromGithub creates a Star from a Github star

func NewStarFromGitlab added in v0.4.0

func NewStarFromGitlab(star gitlab.Project) (*Star, error)

NewStarFromGitlab creates a Star from a Gitlab star

func (*Star) AddTag

func (star *Star) AddTag(db *gorm.DB, tag *Tag) error

AddTag adds a tag to a star

func (*Star) HasTag

func (star *Star) HasTag(tag *Tag) bool

HasTag returns whether a star has a tag. Note that you must call LoadTags first -- no reason to incur a database call each time

func (*Star) Index added in v0.2.0

func (star *Star) Index(index bleve.Index, db *gorm.DB) error

Index adds the star to the index

func (*Star) LoadTags

func (star *Star) LoadTags(db *gorm.DB) error

LoadTags loads the tags for a star

func (*Star) RemoveAllTags

func (star *Star) RemoveAllTags(db *gorm.DB) error

RemoveAllTags removes all tags for a star

func (*Star) RemoveTag

func (star *Star) RemoveTag(db *gorm.DB, tag *Tag) error

RemoveTag removes a tag from a star

type StarResult

type StarResult struct {
	Star  *Star
	Error error
}

StarResult wraps a star and an error

type Tag

type Tag struct {
	gorm.Model
	Name  string
	Stars []Star `gorm:"many2many:star_tags;"`
}

Tag represents a tag in the database

func FindOrCreateTagByName

func FindOrCreateTagByName(db *gorm.DB, name string) (*Tag, bool, error)

FindOrCreateTagByName finds a tag by name, creating if it doesn't exist

func FindTagByName

func FindTagByName(db *gorm.DB, name string) (*Tag, error)

FindTagByName finds a tag by name

func FindTags

func FindTags(db *gorm.DB) ([]Tag, error)

FindTags finds all tags

func (*Tag) Delete

func (tag *Tag) Delete(db *gorm.DB) error

Delete deletes a tag and disassociates it from any stars

func (*Tag) LoadStars

func (tag *Tag) LoadStars(db *gorm.DB, match string) error

LoadStars loads the stars for a tag

func (*Tag) Rename

func (tag *Tag) Rename(db *gorm.DB, name string) error

Rename renames a tag -- new name must not already exist

Jump to

Keyboard shortcuts

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