starmanager

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2018 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const GITHUB string = "api.github.com"

GITHUB - the GitHub API host

View Source
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 Star

type Star struct {
	PushedAt    time.Time `storm:"index"`
	URL         string    `storm:"id,index,unique"`
	Language    string    `storm:"index"`
	Stargazers  int
	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 New

func New() (*StarManager, error)

New - initialize a new starmanager

func (*StarManager) ClearCache

func (s *StarManager) ClearCache() error

ClearCache resets the local db.

func (*StarManager) GetRandomProjects

func (s *StarManager) GetRandomProjects(count int, language, topic string) ([]Star, error)

GetRandomProjects 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() []string

GetTopics returns topics for a repository, otherwise if no repository is passed, returns a list of all topics

func (*StarManager) RemoveOlderThan

func (s *StarManager) RemoveOlderThan(months int) error

RemoveOlderThan removes stars older than a specified time

func (*StarManager) RemoveStar

func (s *StarManager) RemoveStar(star *Star, wg *sync.WaitGroup) (bool, error)

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.

Jump to

Keyboard shortcuts

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