Documentation ¶
Index ¶
- Constants
- type KV
- type Star
- type StarManager
- func (s *StarManager) Cleanup(age int, archived bool) error
- func (s *StarManager) ClearCache() error
- func (s *StarManager) GetProjects(count int, language, topic string, random bool) ([]Star, error)
- func (s *StarManager) GetTopics() []KV
- func (s *StarManager) RemoveStar(star *Star, wg *sync.WaitGroup) (bool, error)
- func (s *StarManager) SaveAllStars() (bool, error)
- func (s *StarManager) SaveIfEmpty()
- func (s *StarManager) SaveStarredPage(pageno int, responses chan *github.Response, wg *sync.WaitGroup) chan error
- func (s *StarManager) SaveStarredRepository(repo *github.Repository, wg *sync.WaitGroup) error
Constants ¶
const CACHEFILE = "stars.db"
CACHEFILE - the filename of the db cache
const CACHEPATH = ".cache"
CACHEPATH - the path to the cache db file
const GITHUB string = "api.github.com"
GITHUB - the GitHub API host
const PAGESIZE int = 100
PAGESIZE - the default response page size (GitHub maximum is 100 so we use that)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type KV ¶ added in v0.2.0
KV is a generic struct that maintains a string key - int value pair ( :( ).
type Star ¶
type Star struct { PushedAt time.Time `storm:"index"` URL string `storm:"id,index,unique"` Language string `storm:"index"` Stargazers int Archived bool `storm:"index"` Description string `storm:"index"` Topics []string `storm:"index"` }
Star represents the starred project that is saved locally
type StarManager ¶
type StarManager struct { Username string Password string Context context.Context Client *github.Client DB *storm.DB }
StarManager - the main object that manages a GitHub user's stars
func (*StarManager) Cleanup ¶ added in v0.3.5
func (s *StarManager) Cleanup(age int, archived bool) error
Cleanup removes stars older than a specified time in months and optionally archived stars.
func (*StarManager) ClearCache ¶
func (s *StarManager) ClearCache() error
ClearCache resets the local db.
func (*StarManager) GetProjects ¶ added in v0.3.7
GetProjects returns random projects given a project count to return, and an optional language and topic to filter by.
func (*StarManager) GetTopics ¶
func (s *StarManager) GetTopics() []KV
GetTopics returns topics for a repository, otherwise if no repository is passed, returns a list of all topics
func (*StarManager) RemoveStar ¶
RemoveStar unstars the project on Github and removes the star from the local cache.
func (*StarManager) SaveAllStars ¶
func (s *StarManager) SaveAllStars() (bool, error)
SaveAllStars saves all stars.
func (*StarManager) SaveIfEmpty ¶
func (s *StarManager) SaveIfEmpty()
SaveIfEmpty saves all stars if the local cache is empty
func (*StarManager) SaveStarredPage ¶
func (s *StarManager) SaveStarredPage(pageno int, responses chan *github.Response, wg *sync.WaitGroup) chan error
SaveStarredPage saves an entire page of starred repositories concurrently, optionally sending server responses to a channel if it is provided.
func (*StarManager) SaveStarredRepository ¶
func (s *StarManager) SaveStarredRepository(repo *github.Repository, wg *sync.WaitGroup) error
SaveStarredRepository saves a single starred project to the local cache.