starmanager

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2019 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const CACHEFILE = "stars.db"

CACHEFILE - the filename of the db cache

View Source
const CACHEPATH = ".cache"

CACHEPATH - the path to the cache db file

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 KV added in v0.2.0

type KV struct {
	Key   string
	Value int
}

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 New

func New() (*StarManager, error)

New - initialize a new starmanager

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

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

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

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